Wednesday, 28 August 2013

Django URLs: How to handle a parameter

Django URLs: How to handle a parameter

In my url.py i have the following line:
url(r'^mypage/(?P<q_id>\d+)/$',
QuizWizard.as_view(generate_form_tuples()), name='nickname'),
QuizWizard is a SessionWizardView
generate_form_tuples is a function (defined inside this module, which has
an optional parameter):
def generate_form_tuples(q_id=1):
...
So, when you get on mypage/ you will (maby) have a q_id. How can i get
this parameter from the url and pass it to the generate_form_tuples()
function ?
P.S. I know that if I redirect this to be handled in a view, the parameter
will be sent automatically having as name : q_id

No comments:

Post a Comment