Ticket #11439: docs-for-r9728.diff

File docs-for-r9728.diff, 2.3 KB (added by Ramiro Morales, 15 years ago)
  • docs/topics/http/urls.txt

    diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
    a b  
    4040       this is the value of the ``ROOT_URLCONF`` setting, but if the incoming
    4141       ``HttpRequest`` object has an attribute called ``urlconf``, its value
    4242       will be used in place of the ``ROOT_URLCONF`` setting.
    43    
     43
    4444    2. Django loads that Python module and looks for the variable
    4545       ``urlpatterns``. This should be a Python list, in the format returned by
    4646       the function ``django.conf.urls.defaults.patterns()``.
    47    
     47
    4848    3. Django runs through each URL pattern, in order, and stops at the first
    4949       one that matches the requested URL.
    50    
     50
    5151    4. Once one of the regexes matches, Django imports and calls the given
    5252       view, which is a simple Python function. The view gets passed an
    5353       :class:`~django.http.HttpRequest` as its first argument and any values
     
    264264-------
    265265
    266266A function that takes a full Python import path to another URLconf that should
    267 be "included" in this place. See `Including other URLconfs`_ below.
     267be "included" in this place.
     268
     269.. versionadded:: 1.1
     270
     271Starting with version 1.1, ``include`` now also accepts as an argument an
     272iterable of URL patterns as returned by the `patterns`_ function instead of
     273just a module string.
     274
     275See `Including other URLconfs`_ below.
    268276
    269277Notes on capturing text in URLs
    270278===============================
     
    391399up to that point and sends the remaining string to the included URLconf for
    392400further processing.
    393401
     402.. versionadded:: 1.1
     403
     404Another posibility is to include additional URL patterns not by specifying the
     405URLconf Python module defining them as the `include`_ argument but by using
     406directly the pattern list as returned by `patterns`_ instead. For example::
     407
     408    from django.conf.urls.defaults import *
     409
     410    extra_patterns = patterns('',
     411        url(r'reports/(?P<id>\d+)/$', 'credit.views.report', name='credit-reports'),
     412        url(r'charge/$', 'credit.views.charge', name='credit-charge'),
     413    )
     414
     415    urlpatterns = patterns('',
     416        url(r'^$',    'apps.main.views.homepage', name='site-homepage'),
     417        (r'^help/',   include('apps.help.urls')),
     418        (r'^credit/', include(extra_patterns)),
     419    )
     420
    394421.. _`Django Web site`: http://www.djangoproject.com/
    395422
    396423Captured parameters
Back to Top