Ticket #11492: doc-fixes-after-r11250.diff

File doc-fixes-after-r11250.diff, 7.0 KB (added by Ramiro Morales, 15 years ago)
  • docs/topics/http/urls.txt

    diff -r e70cbd83611a docs/topics/http/urls.txt
    a b  
    33==============
    44URL dispatcher
    55==============
     6
     7.. module:: django.core.urlresolvers
    68
    79A clean, elegant URL scheme is an important detail in a high-quality Web
    810application. Django lets you design URLs however you want, with no framework
     
    182184patterns
    183185--------
    184186
     187.. function:: patterns(prefix, pattern_description, ...)
     188
    185189A function that takes a prefix, and an arbitrary number of URL patterns, and
    186190returns a list of URL patterns in the format Django needs.
    187191
    188192The first argument to ``patterns()`` is a string ``prefix``. See
    189 "The view prefix" below.
     193`The view prefix`_ below.
    190194
    191195The remaining arguments should be tuples in this format::
    192196
     
    222226
    223227.. versionadded:: 1.0
    224228
     229.. function:: url(regex, view, kwargs=None, name=None, prefix='')
     230
    225231You can use the ``url()`` function, instead of a tuple, as an argument to
    226232``patterns()``. This is convenient if you want to specify a name without the
    227233optional extra arguments dictionary. For example::
     
    244250handler404
    245251----------
    246252
     253.. data:: handler404
     254
    247255A string representing the full Python import path to the view that should be
    248256called if none of the URL patterns match.
    249257
     
    252260
    253261handler500
    254262----------
     263
     264.. data:: handler500
    255265
    256266A string representing the full Python import path to the view that should be
    257267called in case of server errors. Server errors happen when you have runtime
     
    263273include
    264274-------
    265275
     276.. function:: include(<module or pattern_list>)
     277
    266278A function that takes a full Python import path to another URLconf module that
    267279should be "included" in this place.
    268280
    269281.. versionadded:: 1.1
    270282
    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
    272284patterns.
    273285
    274286See `Including other URLconfs`_ below.
     
    421433Admin application. The Django Admin is deployed as instances of a
    422434:class:`AdminSite`; each :class:`AdminSite` instance has an attribute
    423435``urls`` that returns the url patterns available to that instance. It is this
    424 attribute that you ``included()`` into your projects ``urlpatterns`` when you
     436attribute that you ``include()`` into your projects ``urlpatterns`` when you
    425437deploy the admin instance.
    426438
    427439.. _`Django Web site`: http://www.djangoproject.com/
     
    451463Defining URL Namespaces
    452464-----------------------
    453465
    454 When you need to deploying multiple instances of a single application, it can
     466When you need to deploy multiple instances of a single application, it can
    455467be helpful to be able to differentiate between instances. This is especially
    456468important when using _`named URL patterns <naming-url-patterns>`, since
    457469multiple instances of a single application will share named URLs. Namespaces
     
    466478
    467479    * An **instance namespace**. This identifies a specific instance of an
    468480      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
    470482      application namespace. This is used to specify a default instance of an
    471483      application. For example, the default Django Admin instance has an
    472484      instance namespace of ``admin``.
    473485
    474486URL Namespaces can be specified in two ways.
    475487
    476 Firstly, you can provide the applicaiton and instance namespace as arguments
    477 to the ``include()`` when you construct your URL patterns. For example,::
     488Firstly, you can provide the application and instance namespace as arguments
     489to ``include()`` when you construct your URL patterns. For example,::
    478490
    479491    (r'^help/', include('apps.help.urls', namespace='foo', app_name='bar')),
    480492
     
    494506an admin site, plus the name of the admin instance, and the application
    495507namespace ``admin``.
    496508
    497 Once you have defined namespace URLs, you can reverse them. For details on
     509Once you have defined namespaced URLs, you can reverse them. For details on
    498510reversing namespaced urls, see the documentation on :ref:`reversing namespaced
    499511URLs <topics-http-reversing-url-namespaces>`.
    500512
     
    679691
    680692.. versionadded:: 1.1
    681693
    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``.
     694Namespaced URLs are specified using the ``:`` operator. For example, the main
     695index page of the admin application is referenced using ``admin:index``. This
     696indicates a namespace of ``admin``, and a named URL of ``index``.
    685697
    686698Namespaces can also be nested. The named URL ``foo:bar:whiz`` would look for
    687699a pattern named ``whiz`` in the namespace ``bar`` that is itself defined within
    688700the top-level namespace ``foo``.
    689701
    690 When given a namespaced URL (e.g.,, `myapp:index`) to resolve, Django splits
     702When given a namespaced URL (e.g. ``myapp:index``) to resolve, Django splits
    691703the fully qualified name into parts, and then tries the following lookup:
    692704
    693     1. Django then looks for a matching application namespace (in this
     705    1. It looks for a matching application namespace (in this
    694706       example, ``myapp``). This will yield a list of instances of that
    695707       application.
    696708
     
    702714       template.
    703715
    704716       The current application can also be specified manually as an argument
    705        to the :method:``reverse()`` function.
     717       to the :func:`reverse()` function.
    706718
    707719    3. If there is no current application. Django looks for a default
    708720       application instance. The default application instance is the instance
    709721       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``).
    711723
    712724    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.
    714726
    715727    5. If the provided namespace doesn't match an application namespace in
    716728       step 2, Django will attempt a direct lookup of the namespace as an
     
    762774your code, Django provides the following method (in the
    763775``django.core.urlresolvers`` module):
    764776
    765 .. currentmodule:: django.core.urlresolvers
    766777.. function:: reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None)
    767778
    768779``viewname`` is either the function name (either a function reference, or the
     
    812823The :func:`django.core.urlresolvers.resolve` function can be used for resolving
    813824URL paths to the corresponding view functions. It has the following signature:
    814825
    815 .. currentmodule:: django.core.urlresolvers
    816826.. function:: resolve(path, urlconf=None)
    817827
    818828``path`` is the URL path you want to resolve. As with ``reverse()`` above, you
Back to Top