Can someone please explain how you can write a url pattern and view that allows optional parameters? I\'ve done this successfully, but I always break the url template tag.
For anyone who is still having this problem. I use Django 1.5 (updated: using 1.8) and it's still working fine.
I use:
urls.py
url(r'^(?P<app_id>\d+)/start/+(?P<server_id>\d+)?', views.restart, name='restart')
Then when I want to have the two urls
/1/start/2
and
/1/start
I use:
{% url '<namespace>:start' app.id %}
{% url '<namespace>:start' app.id server.id %}
This will create the urls
/1/start/2 and
/1/start/ <- notice the slash.
If you create a url manually you have to keep the / in mind.
I hoop this helps anyone!