When defining URLs in Django you have the option of specifying a name to your URL: url(regex, view, kwargs=None, name=None, prefix='') such as what they do in the tutorial naming it poll_results
:
url(r'^(?P<object_id>\d+)/results/$',
'django.views.generic.list_detail.object_detail',
dict(info_dict, template_name='polls/results.html'), 'poll_results'),
This pattern has one named group: object_id
. The reverse function looks up the URL pattern named poll_results
and passes p.id
to be used for object_id
in the URL pattern. The function returns the URL built from the regex and the passed parameters.