Django url name, some points I'm not sure about -
i'm following steps of django tutorial (part 4). , i'm here. there tag :
{% url 'polls:vote' question.id %} which triggers following line in urls.py file :
url(r'^(?p<question_id>[0-9]+)/vote/$', views.vote, name='vote'), i want sure these points :
question.idvalue passed template engine render template.the variable part (
(?p<question_id>[0-9]+)) in regex replaced first argument inurltag (question.id).the name of variable part (
question_id) name view use handle value (as argument). variable part may have no name (liker'^([0-9]+)/vote/$').there several variable parts (and several arguments passed
{% url %}tag).
could confirm this?
thank you!
a few things:
- question.id in url tag value passed url pattern via view. template specified in view, value ensures unique object (question) in context.
- correct
- the name of view "vote" not question_id. shown in url pattern (views.vote)
- you can pass many values needed via url tag in order match pattern. ensure these values made available via view.
Comments
Post a Comment