Django

Code

Changeset 5946

Show
Ignore:
Timestamp:
08/19/07 10:08:48 (1 year ago)
Author:
mtredinnick
Message:

Used the url() function when adding a named URL pattern, mostly as an example of good practice and to introduce the function. Fixed #4908 (although it wasn't a bug).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/tutorial04.txt

    r5801 r5946  
    194194        (r'^$', 'django.views.generic.list_detail.object_list', info_dict), 
    195195        (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict), 
    196         (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html'), 'poll_results'), 
     196        url(r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html'), 'poll_results'), 
    197197        (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'), 
    198198    ) 
     
    210210      ``object_id`` for the generic views. 
    211211 
    212     * We've added a name, ``poll_results``, to the results view so that we have 
    213       a way to refer to its URL later on (see `naming URL patterns`_ for more on 
    214       named patterns). 
    215        
     212    * We've added a name, ``poll_results``, to the results view so that we 
     213      have a way to refer to its URL later on (see the documentation about 
     214      `naming URL patterns`_ for information). We're also using the `url()`_ 
     215      function from ``django.conf.urls.defaults`` here. It's a good habit to 
     216      use ``url()`` when you are providing a pattern name like this. 
     217 
    216218.. _naming URL patterns: ../url_dispatch/#naming-url-patterns 
     219.. _url(): ../url_dispatch/#url 
    217220 
    218221By default, the ``object_detail`` generic view uses a template called