Django optional url parameters

I have a Django URL like this: url( r’^project_config/(?P<product>\w+)/(?P<project_id>\w+)/$’, ‘tool.views.ProjectConfig’, name=”project_config” ), views.py: def ProjectConfig(request, product, project_id=None, template_name=”project.html”): … # do stuff The problem is that I want the project_id parameter to be optional. I want /project_config/ and /project_config/12345abdce/ to be equally valid URL patterns, so that if project_id is passed, then I can use … Read more

Getting Django admin url for an object

Before Django 1.0 there was an easy way to get the admin url of an object, and I had written a small filter that I’d use like this: <a href=”https://stackoverflow.com/questions/694477/{{ object”admin_url }}” …. > … </a> Basically I was using the url reverse function with the view name being ‘django.contrib.admin.views.main.change_stage’ reverse( ‘django.contrib.admin.views.main.change_stage’, args=[app_label, model_name, object_id] … Read more