Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11492 -- Corrected some typos, and added some extra markup for…

… the URLs documentation. Thanks to Ramiro Morales for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11258 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0c9d0bf7d653336c5ee7d15f23adeb098a9f5dba 1 parent 3469f4b
Russell Keith-Magee authored July 17, 2009

Showing 1 changed file with 27 additions and 17 deletions. Show diff stats Hide diff stats

  1. 44  docs/topics/http/urls.txt
44  docs/topics/http/urls.txt
@@ -4,6 +4,8 @@
4 4
 URL dispatcher
5 5
 ==============
6 6
 
  7
+.. module:: django.core.urlresolvers
  8
+
7 9
 A clean, elegant URL scheme is an important detail in a high-quality Web
8 10
 application. Django lets you design URLs however you want, with no framework
9 11
 limitations.
@@ -182,11 +184,13 @@ your URLconf. This gives your module access to these objects:
182 184
 patterns
183 185
 --------
184 186
 
  187
+.. function:: patterns(prefix, pattern_description, ...)
  188
+
185 189
 A function that takes a prefix, and an arbitrary number of URL patterns, and
186 190
 returns a list of URL patterns in the format Django needs.
187 191
 
188 192
 The first argument to ``patterns()`` is a string ``prefix``. See
189  
-"The view prefix" below.
  193
+`The view prefix`_ below.
190 194
 
191 195
 The remaining arguments should be tuples in this format::
192 196
 
@@ -222,6 +226,8 @@ url
222 226
 
223 227
 .. versionadded:: 1.0
224 228
 
  229
+.. function:: url(regex, view, kwargs=None, name=None, prefix='')
  230
+
225 231
 You can use the ``url()`` function, instead of a tuple, as an argument to
226 232
 ``patterns()``. This is convenient if you want to specify a name without the
227 233
 optional extra arguments dictionary. For example::
@@ -244,6 +250,8 @@ The ``prefix`` parameter has the same meaning as the first argument to
244 250
 handler404
245 251
 ----------
246 252
 
  253
+.. data:: handler404
  254
+
247 255
 A string representing the full Python import path to the view that should be
248 256
 called if none of the URL patterns match.
249 257
 
@@ -253,6 +261,8 @@ value should suffice.
253 261
 handler500
254 262
 ----------
255 263
 
  264
+.. data:: handler500
  265
+
256 266
 A string representing the full Python import path to the view that should be
257 267
 called in case of server errors. Server errors happen when you have runtime
258 268
 errors in view code.
@@ -263,12 +273,14 @@ value should suffice.
263 273
 include
264 274
 -------
265 275
 
  276
+.. function:: include(<module or pattern_list>)
  277
+
266 278
 A function that takes a full Python import path to another URLconf module that
267 279
 should be "included" in this place.
268 280
 
269 281
 .. versionadded:: 1.1
270 282
 
271  
-:meth:``include`` also accepts as an argument an iterable that returns URL
  283
+:func:`include` also accepts as an argument an iterable that returns URL
272 284
 patterns.
273 285
 
274 286
 See `Including other URLconfs`_ below.
@@ -421,7 +433,7 @@ This approach can be seen in use when you deploy an instance of the Django
421 433
 Admin application. The Django Admin is deployed as instances of a
422 434
 :class:`AdminSite`; each :class:`AdminSite` instance has an attribute
423 435
 ``urls`` that returns the url patterns available to that instance. It is this
424  
-attribute that you ``included()`` into your projects ``urlpatterns`` when you
  436
+attribute that you ``include()`` into your projects ``urlpatterns`` when you
425 437
 deploy the admin instance.
426 438
 
427 439
 .. _`Django Web site`: http://www.djangoproject.com/
@@ -466,15 +478,15 @@ A URL namespace comes in two parts, both of which are strings:
466 478
 
467 479
     * An **instance namespace**. This identifies a specific instance of an
468 480
       application. Instance namespaces should be unique across your entire
469  
-      project. However, and instance namespace can be the same as the
  481
+      project. However, an instance namespace can be the same as the
470 482
       application namespace. This is used to specify a default instance of an
471 483
       application. For example, the default Django Admin instance has an
472 484
       instance namespace of ``admin``.
473 485
 
474 486
 URL Namespaces can be specified in two ways.
475 487
 
476  
-Firstly, you can provide the applicaiton and instance namespace as arguments
477  
-to the ``include()`` when you construct your URL patterns. For example,::
  488
+Firstly, you can provide the application and instance namespace as arguments
  489
+to ``include()`` when you construct your URL patterns. For example,::
478 490
 
479 491
     (r'^help/', include('apps.help.urls', namespace='foo', app_name='bar')),
480 492
 
@@ -494,7 +506,7 @@ instance namespace. For example, the ``urls`` attribute of Django's
494 506
 an admin site, plus the name of the admin instance, and the application
495 507
 namespace ``admin``.
496 508
 
497  
-Once you have defined namespace URLs, you can reverse them. For details on
  509
+Once you have defined namespaced URLs, you can reverse them. For details on
498 510
 reversing namespaced urls, see the documentation on :ref:`reversing namespaced
499 511
 URLs <topics-http-reversing-url-namespaces>`.
500 512
 
@@ -679,18 +691,18 @@ URL namespaces
679 691
 
680 692
 .. versionadded:: 1.1
681 693
 
682  
-Namespaced URLs are specified using the `:` operator. For example, the main index
683  
-page of the admin application is referenced using ``admin:index``. This indicates
684  
-a namespace of ``admin``, and a named URL of ``index``.
  694
+Namespaced URLs are specified using the ``:`` operator. For example, the main
  695
+index page of the admin application is referenced using ``admin:index``. This
  696
+indicates a namespace of ``admin``, and a named URL of ``index``.
685 697
 
686 698
 Namespaces can also be nested. The named URL ``foo:bar:whiz`` would look for
687 699
 a pattern named ``whiz`` in the namespace ``bar`` that is itself defined within
688 700
 the top-level namespace ``foo``.
689 701
 
690  
-When given a namespaced URL (e.g.,, `myapp:index`) to resolve, Django splits
  702
+When given a namespaced URL (e.g. ``myapp:index``) to resolve, Django splits
691 703
 the fully qualified name into parts, and then tries the following lookup:
692 704
 
693  
-    1. Django then looks for a matching application namespace (in this
  705
+    1. First, Django looks for a matching application namespace (in this
694 706
        example, ``myapp``). This will yield a list of instances of that
695 707
        application.
696 708
 
@@ -702,15 +714,15 @@ the fully qualified name into parts, and then tries the following lookup:
702 714
        template.
703 715
 
704 716
        The current application can also be specified manually as an argument
705  
-       to the :method:``reverse()`` function.
  717
+       to the :func:`reverse()` function.
706 718
 
707 719
     3. If there is no current application. Django looks for a default
708 720
        application instance. The default application instance is the instance
709 721
        that has an instance namespace matching the application namespace (in
710  
-       this example, an instance of the ``myapp`` called ``myapp``)
  722
+       this example, an instance of the ``myapp`` called ``myapp``).
711 723
 
712 724
     4. If there is no default application instance, Django will pick the first
713  
-       deployed instance of the application, whatever it's instance name may be.
  725
+       deployed instance of the application, whatever its instance name may be.
714 726
 
715 727
     5. If the provided namespace doesn't match an application namespace in
716 728
        step 2, Django will attempt a direct lookup of the namespace as an
@@ -762,7 +774,6 @@ If you need to use something similar to the :ttag:`url` template tag in
762 774
 your code, Django provides the following method (in the
763 775
 ``django.core.urlresolvers`` module):
764 776
 
765  
-.. currentmodule:: django.core.urlresolvers
766 777
 .. function:: reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None)
767 778
 
768 779
 ``viewname`` is either the function name (either a function reference, or the
@@ -812,7 +823,6 @@ resolve()
812 823
 The :func:`django.core.urlresolvers.resolve` function can be used for resolving
813 824
 URL paths to the corresponding view functions. It has the following signature:
814 825
 
815  
-.. currentmodule:: django.core.urlresolvers
816 826
 .. function:: resolve(path, urlconf=None)
817 827
 
818 828
 ``path`` is the URL path you want to resolve. As with ``reverse()`` above, you

0 notes on commit 0c9d0bf

Please sign in to comment.
Something went wrong with that request. Please try again.