Ticket #14743: urls-doc-fixes.diff

File urls-doc-fixes.diff, 4.9 KB (added by adamv, 5 years ago)
  • docs/topics/http/urls.txt

    diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
    index ac85d05..94a8115 100644
    a b When a user requests a page from your Django-powered site, this is the 
    3737algorithm the system follows to determine which Python code to execute:
    3838
    3939    1. Django determines the root URLconf module to use. Ordinarily,
    40        this is the value of the ``ROOT_URLCONF`` setting, but if the incoming
     40       this is the value of the :setting:`ROOT_URLCONF` setting, but if the incoming
    4141       ``HttpRequest`` object has an attribute called ``urlconf`` (set by
    4242       middleware :ref:`request processing <request-middleware>`), its value
    43        will be used in place of the ``ROOT_URLCONF`` setting.
     43       will be used in place of the :setting:`ROOT_URLCONF` setting.
    4444
    4545    2. Django loads that Python module and looks for the variable
    4646       ``urlpatterns``. This should be a Python list, in the format returned by
    47        the function ``django.conf.urls.defaults.patterns()``.
     47       the function :func:`django.conf.urls.defaults.patterns`.
    4848
    4949    3. Django runs through each URL pattern, in order, and stops at the first
    5050       one that matches the requested URL.
    Syntax of the urlpatterns variable 
    174174==================================
    175175
    176176``urlpatterns`` should be a Python list, in the format returned by the function
    177 ``django.conf.urls.defaults.patterns()``. Always use ``patterns()`` to create
     177:func:`django.conf.urls.defaults.patterns`. Always use ``patterns()`` to create
    178178the ``urlpatterns`` variable.
    179179
    180180Convention is to use ``from django.conf.urls.defaults import *`` at the top of
    181181your URLconf. This gives your module access to these objects:
    182182
     183.. module:: django.conf.urls.defaults
     184
    183185patterns
    184186--------
    185187
    directly the pattern list as returned by `patterns`_ instead. For example:: 
    436438
    437439This approach can be seen in use when you deploy an instance of the Django
    438440Admin application. The Django Admin is deployed as instances of a
    439 :class:`AdminSite`; each :class:`AdminSite` instance has an attribute
    440 ``urls`` that returns the url patterns available to that instance. It is this
    441 attribute that you ``include()`` into your projects ``urlpatterns`` when you
    442 deploy the admin instance.
     441:class:`~django.contrib.admin.AdminSite`; each
     442:class:`~django.contrib.admin.AdminSite` instance has an attribute ``urls``
     443that returns the url patterns available to that instance. It is this attribute
     444that you ``include()`` into your projects ``urlpatterns`` when you deploy the
     445admin instance.
    443446
    444447.. _`Django Web site`: http://www.djangoproject.com/
    445448
    a 3-tuple containing:: 
    507510
    508511This will include the nominated URL patterns into the given application and
    509512instance namespace. For example, the ``urls`` attribute of Django's
    510 :class:`AdminSite` object returns a 3-tuple that contains all the patterns in
    511 an admin site, plus the name of the admin instance, and the application
    512 namespace ``admin``.
     513:class:`~django.contrib.admin.AdminSite` object returns a 3-tuple that contains
     514all the patterns in an admin site, plus the name of the admin instance, and the
     515application namespace ``admin``.
    513516
    514517Once you have defined namespaced URLs, you can reverse them. For details on
    515518reversing namespaced urls, see the documentation on :ref:`reversing namespaced
    following signature: 
    834837``path`` is the URL path you want to resolve. As with
    835838:func:`~django.core.urlresolvers.reverse`, you don't need to
    836839worry about the ``urlconf`` parameter. The function returns a
    837 :class:`django.core.urlresolvers.ResolverMatch` object that allows you
     840:class:`ResolverMatch` object that allows you
    838841to access various meta-data about the resolved URL.
    839842
    840843If the URL does not resolve, the function raises an
    841844:class:`~django.http.Http404` exception.
    842845
    843 .. class:: ResolverMatch()
     846.. class:: ResolverMatch
    844847
    845848    .. attribute:: ResolverMatch.func
    846849
    If the URL does not resolve, the function raises an 
    875878        The list of individual namespace components in the full
    876879        instance namespace for the URL pattern that matches the URL.
    877880        i.e., if the namespace is ``foo:bar``, then namespaces will be
    878         ``[`foo`, `bar`]``.
     881        ``['foo', 'bar']``.
    879882
    880 A :class:`~django.core.urlresolvers.ResolverMatch` object can then be
    881 interrogated to provide information about the URL pattern that matches
    882 a URL::
     883A :class:`ResolverMatch` object can then be interrogated to provide
     884information about the URL pattern that matches a URL::
    883885
    884886    # Resolve a URL
    885887    match = resolve('/some/path/')
    886888    # Print the URL pattern that matches the URL
    887889    print match.url_name
    888890
    889 A :class:`~django.core.urlresolvers.ResolverMatch` object can also be
    890 assigned to a triple::
     891A :class:`ResolverMatch` object can also be assigned to a triple::
    891892
    892893    func, args, kwargs = resolve('/some/path/')
    893894
Back to Top