diff options
| author | Tim Graham <timograham@gmail.com> | 2015-08-17 10:45:00 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-23 19:31:09 -0400 |
| commit | a25d3ce007b90a0516aed54fc1c5a16510a290e4 (patch) | |
| tree | f8d0566d2d46a2e609cf0d782f0c9cf876ee8409 /docs/ref | |
| parent | 3f50dc2be51ee68ce64ac1faadc91193f03fbe3f (diff) | |
Refs #22218 -- Removed conf.urls.patterns() per deprecation timeline.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/urls.txt | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/docs/ref/urls.txt b/docs/ref/urls.txt index 1fb9375b79..2b40c9eaf6 100644 --- a/docs/ref/urls.txt +++ b/docs/ref/urls.txt @@ -4,77 +4,6 @@ .. module:: django.conf.urls -patterns() ----------- - -.. function:: patterns(prefix, pattern_description, ...) - -.. deprecated:: 1.8 - - ``urlpatterns`` should be a plain list of :func:`django.conf.urls.url` - instances instead. - -A function that takes a prefix, and an arbitrary number of URL patterns, and -returns a list of URL patterns in the format Django needs. - -The first argument to ``patterns()`` is a string ``prefix``. Here's the example -URLconf from the :doc:`Django overview </intro/overview>`:: - - from django.conf.urls import patterns, url - - urlpatterns = patterns('', - url(r'^articles/([0-9]{4})/$', 'news.views.year_archive'), - url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'news.views.month_archive'), - url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'news.views.article_detail'), - ) - -In this example, each view has a common prefix -- ``'news.views'``. -Instead of typing that out for each entry in ``urlpatterns``, you can use the -first argument to the ``patterns()`` function to specify a prefix to apply to -each view function. - -With this in mind, the above example can be written more concisely as:: - - from django.conf.urls import patterns, url - - urlpatterns = patterns('news.views', - url(r'^articles/([0-9]{4})/$', 'year_archive'), - url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'month_archive'), - url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'article_detail'), - ) - -Note that you don't put a trailing dot (``"."``) in the prefix. Django puts -that in automatically. - -The remaining arguments should be tuples in this format:: - - (regular expression, Python callback function [, optional_dictionary [, optional_name]]) - -The ``optional_dictionary`` and ``optional_name`` parameters are described in -:ref:`Passing extra options to view functions <views-extra-options>`. - -.. note:: - Because ``patterns()`` is a function call, it accepts a maximum of 255 - arguments (URL patterns, in this case). This is a limit for all Python - function calls. This is rarely a problem in practice, because you'll - typically structure your URL patterns modularly by using ``include()`` - sections. However, on the off-chance you do hit the 255-argument limit, - realize that ``patterns()`` returns a Python list, so you can split up the - construction of the list. - - :: - - urlpatterns = patterns('', - ... - ) - urlpatterns += patterns('', - ... - ) - - Python lists have unlimited size, so there's no limit to how many URL - patterns you can construct. The only limit is that you can only create 254 - at a time (the 255th argument is the initial prefix argument). - static() -------- |
