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
|
37 | 37 | algorithm the system follows to determine which Python code to execute: |
38 | 38 | |
39 | 39 | 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 |
41 | 41 | ``HttpRequest`` object has an attribute called ``urlconf`` (set by |
42 | 42 | 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. |
44 | 44 | |
45 | 45 | 2. Django loads that Python module and looks for the variable |
46 | 46 | ``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`. |
48 | 48 | |
49 | 49 | 3. Django runs through each URL pattern, in order, and stops at the first |
50 | 50 | one that matches the requested URL. |
… |
… |
Syntax of the urlpatterns variable
|
174 | 174 | ================================== |
175 | 175 | |
176 | 176 | ``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 |
178 | 178 | the ``urlpatterns`` variable. |
179 | 179 | |
180 | 180 | Convention is to use ``from django.conf.urls.defaults import *`` at the top of |
181 | 181 | your URLconf. This gives your module access to these objects: |
182 | 182 | |
| 183 | .. module:: django.conf.urls.defaults |
| 184 | |
183 | 185 | patterns |
184 | 186 | -------- |
185 | 187 | |
… |
… |
directly the pattern list as returned by `patterns`_ instead. For example::
|
436 | 438 | |
437 | 439 | This approach can be seen in use when you deploy an instance of the Django |
438 | 440 | Admin 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`` |
| 443 | that returns the url patterns available to that instance. It is this attribute |
| 444 | that you ``include()`` into your projects ``urlpatterns`` when you deploy the |
| 445 | admin instance. |
443 | 446 | |
444 | 447 | .. _`Django Web site`: http://www.djangoproject.com/ |
445 | 448 | |
… |
… |
a 3-tuple containing::
|
507 | 510 | |
508 | 511 | This will include the nominated URL patterns into the given application and |
509 | 512 | instance 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 |
| 514 | all the patterns in an admin site, plus the name of the admin instance, and the |
| 515 | application namespace ``admin``. |
513 | 516 | |
514 | 517 | Once you have defined namespaced URLs, you can reverse them. For details on |
515 | 518 | reversing namespaced urls, see the documentation on :ref:`reversing namespaced |
… |
… |
following signature:
|
834 | 837 | ``path`` is the URL path you want to resolve. As with |
835 | 838 | :func:`~django.core.urlresolvers.reverse`, you don't need to |
836 | 839 | worry 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 |
838 | 841 | to access various meta-data about the resolved URL. |
839 | 842 | |
840 | 843 | If the URL does not resolve, the function raises an |
841 | 844 | :class:`~django.http.Http404` exception. |
842 | 845 | |
843 | | .. class:: ResolverMatch() |
| 846 | .. class:: ResolverMatch |
844 | 847 | |
845 | 848 | .. attribute:: ResolverMatch.func |
846 | 849 | |
… |
… |
If the URL does not resolve, the function raises an
|
875 | 878 | The list of individual namespace components in the full |
876 | 879 | instance namespace for the URL pattern that matches the URL. |
877 | 880 | i.e., if the namespace is ``foo:bar``, then namespaces will be |
878 | | ``[`foo`, `bar`]``. |
| 881 | ``['foo', 'bar']``. |
879 | 882 | |
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:: |
| 883 | A :class:`ResolverMatch` object can then be interrogated to provide |
| 884 | information about the URL pattern that matches a URL:: |
883 | 885 | |
884 | 886 | # Resolve a URL |
885 | 887 | match = resolve('/some/path/') |
886 | 888 | # Print the URL pattern that matches the URL |
887 | 889 | print match.url_name |
888 | 890 | |
889 | | A :class:`~django.core.urlresolvers.ResolverMatch` object can also be |
890 | | assigned to a triple:: |
| 891 | A :class:`ResolverMatch` object can also be assigned to a triple:: |
891 | 892 | |
892 | 893 | func, args, kwargs = resolve('/some/path/') |
893 | 894 | |