Store Boolean Variable In Url Dispatching
The following url definition should pass whether results/ is present in the url: url(r'^(?P[0-9]+)/(?P(results/)?)shorten/$', views.shorten, name=
Solution 1:
You could have two URL patterns and pass results
in the kwargs:
url(r'^(?P<question_id>[0-9]+)/results/shorten/$', views.shorten, {'results': True}, name='shorten'),
url(r'^(?P<question_id>[0-9]+)/shorten/$', views.shorten, {'results': False}, name='shorten'),
If you don't want to do this, then there isn't currently a simple way to cast the results
string to a boolean value. You could write a middleware or decorator, but that would be overkill.
Post a Comment for "Store Boolean Variable In Url Dispatching"