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 :

  1. question.id value passed template engine render template.

  2. the variable part ((?p<question_id>[0-9]+)) in regex replaced first argument in url tag (question.id).

  3. the name of variable part (question_id) name view use handle value (as argument). variable part may have no name (like r'^([0-9]+)/vote/$').

  4. there several variable parts (and several arguments passed {% url %} tag).

could confirm this?

thank you!

a few things:

  1. question.id in url tag value passed url pattern via view. template specified in view, value ensures unique object (question) in context.
  2. correct
  3. the name of view "vote" not question_id. shown in url pattern (views.vote)
  4. you can pass many values needed via url tag in order match pattern. ensure these values made available via view.

Comments