-
diff --git a/django/conf/urls/__init__.py b/django/conf/urls/__init__.py
index e69de29..6084bf8 100644
a
|
b
|
|
| 1 | from django.conf.urls.defaults import * |
-
diff --git a/django/conf/urls/i18n.py b/django/conf/urls/i18n.py
index 00e2d60..34a93e2 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | urlpatterns = patterns('', |
4 | 4 | (r'^setlang/$', 'django.views.i18n.set_language'), |
-
diff --git a/django/conf/urls/shortcut.py b/django/conf/urls/shortcut.py
index 135f3be..6eb2e55 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | urlpatterns = patterns('django.views', |
4 | 4 | (r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'), |
-
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 787f856..d1792ad 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
309 | 309 | super(ModelAdmin, self).__init__() |
310 | 310 | |
311 | 311 | def get_urls(self): |
312 | | from django.conf.urls.defaults import patterns, url |
| 312 | from django.conf.urls import patterns, url |
313 | 313 | |
314 | 314 | def wrap(view): |
315 | 315 | def wrapper(*args, **kwargs): |
-
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index a0338ee..d049758 100644
a
|
b
|
class AdminSite(object):
|
178 | 178 | class MyAdminSite(AdminSite): |
179 | 179 | |
180 | 180 | def get_urls(self): |
181 | | from django.conf.urls.defaults import patterns, url |
| 181 | from django.conf.urls import patterns, url |
182 | 182 | |
183 | 183 | urls = super(MyAdminSite, self).get_urls() |
184 | 184 | urls += patterns('', |
… |
… |
class AdminSite(object):
|
203 | 203 | return update_wrapper(inner, view) |
204 | 204 | |
205 | 205 | def get_urls(self): |
206 | | from django.conf.urls.defaults import patterns, url, include |
| 206 | from django.conf.urls import patterns, url, include |
207 | 207 | |
208 | 208 | if settings.DEBUG: |
209 | 209 | self.check_dependencies() |
-
diff --git a/django/contrib/admindocs/urls.py b/django/contrib/admindocs/urls.py
index 57edb56..4f50049 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from django.contrib.admindocs import views |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 7d855d8..a8508fc 100644
a
|
b
|
class UserAdmin(admin.ModelAdmin):
|
73 | 73 | return super(UserAdmin, self).get_form(request, obj, **defaults) |
74 | 74 | |
75 | 75 | def get_urls(self): |
76 | | from django.conf.urls.defaults import patterns |
| 76 | from django.conf.urls import patterns |
77 | 77 | return patterns('', |
78 | 78 | (r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password)) |
79 | 79 | ) + super(UserAdmin, self).get_urls() |
-
diff --git a/django/contrib/auth/urls.py b/django/contrib/auth/urls.py
index 42b4e8f..7106153 100644
a
|
b
|
|
2 | 2 | # provided as a convenience to those who want to deploy these URLs elsewhere. |
3 | 3 | # This file is also used to provide a reliable view deployment for test purposes. |
4 | 4 | |
5 | | from django.conf.urls.defaults import * |
| 5 | from django.conf.urls import patterns |
6 | 6 | |
7 | 7 | urlpatterns = patterns('', |
8 | 8 | (r'^login/$', 'django.contrib.auth.views.login'), |
-
diff --git a/django/contrib/comments/urls.py b/django/contrib/comments/urls.py
index d903779..69a0222 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | |
3 | 3 | urlpatterns = patterns('django.contrib.comments.views', |
4 | 4 | url(r'^post/$', 'comments.post_comment', name='comments-post-comment'), |
-
diff --git a/django/contrib/databrowse/urls.py b/django/contrib/databrowse/urls.py
index 9b85d14..5c431de 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | from django.contrib.databrowse import views |
3 | 3 | |
4 | 4 | # Note: The views in this URLconf all require a 'models' argument, |
-
diff --git a/django/contrib/flatpages/tests/urls.py b/django/contrib/flatpages/tests/urls.py
index 3cffd09..e0e7a07 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
2 | 2 | |
3 | 3 | # special urls for flatpage test cases |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/django/contrib/flatpages/urls.py b/django/contrib/flatpages/urls.py
index 4928930..5abb8e1 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | urlpatterns = patterns('django.contrib.flatpages.views', |
4 | 4 | (r'^(?P<url>.*)$', 'flatpage'), |
-
diff --git a/django/contrib/formtools/tests/urls.py b/django/contrib/formtools/tests/urls.py
index 6fc1e4e..d866943 100644
a
|
b
|
|
2 | 2 | This is a URLconf to be loaded by tests.py. Add any URLs needed for tests only. |
3 | 3 | """ |
4 | 4 | |
5 | | from django.conf.urls.defaults import * |
| 5 | from django.conf.urls import patterns |
6 | 6 | from django.contrib.formtools.tests import * |
7 | 7 | |
8 | 8 | urlpatterns = patterns('', |
-
diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py
index edaf280..6a64430 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | from feeds import feed_dict |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py
index 5191f34..d617a1b 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | from django.contrib import messages |
3 | 3 | from django.core.urlresolvers import reverse |
4 | 4 | from django.http import HttpResponseRedirect, HttpResponse |
-
diff --git a/django/contrib/sitemaps/tests/urls.py b/django/contrib/sitemaps/tests/urls.py
index 03b060d..c264f94 100644
a
|
b
|
|
1 | 1 | from datetime import datetime |
2 | | from django.conf.urls.defaults import * |
| 2 | from django.conf.urls import patterns |
3 | 3 | from django.contrib.sitemaps import Sitemap, GenericSitemap, FlatPageSitemap |
4 | 4 | from django.contrib.auth.models import User |
5 | 5 | |
-
diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt
index 34572a6..737db21 100644
a
|
b
|
decouple URLs from Python code.
|
176 | 176 | Here's what a URLconf might look like for the ``Reporter``/``Article`` |
177 | 177 | example above:: |
178 | 178 | |
179 | | from django.conf.urls.defaults import * |
| 179 | from django.conf.urls import patterns, url, include |
180 | 180 | |
181 | 181 | urlpatterns = patterns('', |
182 | 182 | (r'^articles/(\d{4})/$', 'news.views.year_archive'), |
-
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt
index bae47c8..cff907d 100644
a
|
b
|
activate the admin site for your installation, do these three things:
|
40 | 40 | |
41 | 41 | .. parsed-literal:: |
42 | 42 | |
43 | | from django.conf.urls.defaults import * |
| 43 | from django.conf.urls import patterns, url, include |
44 | 44 | |
45 | 45 | # Uncomment the next two lines to enable the admin: |
46 | 46 | **from django.contrib import admin** |
-
diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
index bb851b7..5d5a9cd 100644
a
|
b
|
point at that file::
|
78 | 78 | |
79 | 79 | Time for an example. Edit ``mysite/urls.py`` so it looks like this:: |
80 | 80 | |
81 | | from django.conf.urls.defaults import * |
| 81 | from django.conf.urls import patterns, url, include |
82 | 82 | |
83 | 83 | from django.contrib import admin |
84 | 84 | admin.autodiscover() |
… |
… |
It's just a normal view.
|
366 | 366 | You normally won't have to bother with writing 404 views. By default, URLconfs |
367 | 367 | have the following line up top:: |
368 | 368 | |
369 | | from django.conf.urls.defaults import * |
| 369 | from django.conf.urls import patterns, url, include |
370 | 370 | |
371 | 371 | That takes care of setting ``handler404`` in the current module. As you can see |
372 | 372 | in ``django/conf/urls/defaults.py``, ``handler404`` is set to |
… |
… |
callback in your URLconf, you can concatenate multiple
|
459 | 459 | :func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might |
460 | 460 | now look like this:: |
461 | 461 | |
462 | | from django.conf.urls.defaults import * |
| 462 | from django.conf.urls import patterns, url, include |
463 | 463 | |
464 | 464 | from django.contrib import admin |
465 | 465 | admin.autodiscover() |
… |
… |
Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change
|
496 | 496 | :func:`~django.conf.urls.defaults.include`, leaving you with:: |
497 | 497 | |
498 | 498 | # This also imports the include function |
499 | | from django.conf.urls.defaults import * |
| 499 | from django.conf.urls import patterns, url, include |
500 | 500 | |
501 | 501 | from django.contrib import admin |
502 | 502 | admin.autodiscover() |
… |
… |
URLconf by removing the leading "polls/" from each line, and removing the
|
526 | 526 | lines registering the admin site. Your ``polls.urls`` file should now look like |
527 | 527 | this:: |
528 | 528 | |
529 | | from django.conf.urls.defaults import * |
| 529 | from django.conf.urls import patterns, url, include |
530 | 530 | |
531 | 531 | urlpatterns = patterns('polls.views', |
532 | 532 | (r'^$', 'index'), |
-
diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt
index ded5cb2..dd8a29f 100644
a
|
b
|
Read on for details.
|
218 | 218 | First, open the ``polls/urls.py`` URLconf. It looks like this, according to the |
219 | 219 | tutorial so far:: |
220 | 220 | |
221 | | from django.conf.urls.defaults import * |
| 221 | from django.conf.urls import patterns, url, include |
222 | 222 | |
223 | 223 | urlpatterns = patterns('polls.views', |
224 | 224 | (r'^$', 'index'), |
… |
… |
tutorial so far::
|
229 | 229 | |
230 | 230 | Change it like so:: |
231 | 231 | |
232 | | from django.conf.urls.defaults import * |
| 232 | from django.conf.urls import patterns, url, include |
233 | 233 | from django.views.generic import DetailView, ListView |
234 | 234 | from polls.models import Poll |
235 | 235 | |
-
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index fb48ba8..5830019 100644
a
|
b
|
In this example, we register the default ``AdminSite`` instance
|
1735 | 1735 | ``django.contrib.admin.site`` at the URL ``/admin/`` :: |
1736 | 1736 | |
1737 | 1737 | # urls.py |
1738 | | from django.conf.urls.defaults import * |
| 1738 | from django.conf.urls import patterns, url, include |
1739 | 1739 | from django.contrib import admin |
1740 | 1740 | |
1741 | 1741 | admin.autodiscover() |
… |
… |
In this example, we register the ``AdminSite`` instance
|
1751 | 1751 | ``myproject.admin.admin_site`` at the URL ``/myadmin/`` :: |
1752 | 1752 | |
1753 | 1753 | # urls.py |
1754 | | from django.conf.urls.defaults import * |
| 1754 | from django.conf.urls import patterns, url, include |
1755 | 1755 | from myproject.admin import admin_site |
1756 | 1756 | |
1757 | 1757 | urlpatterns = patterns('', |
… |
… |
separate versions of the admin site -- using the ``AdminSite`` instances
|
1775 | 1775 | respectively:: |
1776 | 1776 | |
1777 | 1777 | # urls.py |
1778 | | from django.conf.urls.defaults import * |
| 1778 | from django.conf.urls import patterns, url, include |
1779 | 1779 | from myproject.admin import basic_site, advanced_site |
1780 | 1780 | |
1781 | 1781 | urlpatterns = patterns('', |
-
diff --git a/docs/ref/contrib/comments/example.txt b/docs/ref/contrib/comments/example.txt
index 921fe03..0847209 100644
a
|
b
|
enable it in your project's ``urls.py``:
|
140 | 140 | |
141 | 141 | .. code-block:: python |
142 | 142 | |
143 | | from django.conf.urls.defaults import * |
| 143 | from django.conf.urls import patterns, url, include |
144 | 144 | from django.contrib.comments.feeds import LatestCommentFeed |
145 | 145 | |
146 | 146 | urlpatterns = patterns('', |
-
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index ea6b038..c4c6bac 100644
a
|
b
|
deploy the new :class:`FormWizard` object a URL in ``urls.py``. The
|
190 | 190 | wizard takes a list of your :class:`~django.forms.Form` objects as |
191 | 191 | arguments when you instantiate the Wizard:: |
192 | 192 | |
193 | | from django.conf.urls.defaults import * |
| 193 | from django.conf.urls import patterns, url, include |
194 | 194 | from testapp.forms import ContactForm1, ContactForm2, ContactWizard |
195 | 195 | |
196 | 196 | urlpatterns = patterns('', |
-
diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt
index d386180..af72eca 100644
a
|
b
|
Let's dive in again -- create a file called ``admin.py`` inside the
|
701 | 701 | Next, edit your ``urls.py`` in the ``geodjango`` project folder to look |
702 | 702 | as follows:: |
703 | 703 | |
704 | | from django.conf.urls.defaults import * |
| 704 | from django.conf.urls import patterns, url, include |
705 | 705 | from django.contrib.gis import admin |
706 | 706 | |
707 | 707 | admin.autodiscover() |
-
diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt
index d7dcc2e..aa0162e 100644
a
|
b
|
Example
|
241 | 241 | |
242 | 242 | Here's an example of a :doc:`URLconf </topics/http/urls>` using both:: |
243 | 243 | |
244 | | from django.conf.urls.defaults import * |
| 244 | from django.conf.urls import patterns, url, include |
245 | 245 | from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap |
246 | 246 | from blog.models import Entry |
247 | 247 | |
-
diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt
index 9a0aa9b..bda1dd2 100644
a
|
b
|
latest five news items::
|
80 | 80 | To connect a URL to this feed, put an instance of the Feed object in |
81 | 81 | your :doc:`URLconf </topics/http/urls>`. For example:: |
82 | 82 | |
83 | | from django.conf.urls.defaults import * |
| 83 | from django.conf.urls import patterns, url, include |
84 | 84 | from myproject.feeds import LatestEntriesFeed |
85 | 85 | |
86 | 86 | urlpatterns = patterns('', |
… |
… |
Here's a full example::
|
327 | 327 | |
328 | 328 | And the accompanying URLconf:: |
329 | 329 | |
330 | | from django.conf.urls.defaults import * |
| 330 | from django.conf.urls import patterns, url, include |
331 | 331 | from myproject.feeds import RssSiteNewsFeed, AtomSiteNewsFeed |
332 | 332 | |
333 | 333 | urlpatterns = patterns('', |
-
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 02b9fae..2a1f885 100644
a
|
b
|
reference the name rather than the view function. A named URL
|
499 | 499 | pattern is defined by replacing the pattern tuple by a call to |
500 | 500 | the ``url`` function):: |
501 | 501 | |
502 | | from django.conf.urls.defaults import * |
| 502 | from django.conf.urls import patterns, url, include |
503 | 503 | |
504 | 504 | url(r'^people/(\d+)/$', |
505 | 505 | 'django.views.generic.list_detail.object_detail', |
-
diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt
index 01d5f2f..3c31154 100644
a
|
b
|
views themselves are classes, we point the URL to the as_view class method
|
75 | 75 | instead, which is the entrypoint for class-based views:: |
76 | 76 | |
77 | 77 | # urls.py |
78 | | from django.conf.urls.defaults import * |
| 78 | from django.conf.urls import patterns, url, include |
79 | 79 | from some_app.views import AboutView |
80 | 80 | |
81 | 81 | urlpatterns = patterns('', |
… |
… |
Alternatively, if you're only changing a few simple attributes on a
|
86 | 86 | class-based view, you can simply pass the new attributes into the as_view |
87 | 87 | method call itself:: |
88 | 88 | |
89 | | from django.conf.urls.defaults import * |
| 89 | from django.conf.urls import patterns, url, include |
90 | 90 | from django.views.generic import TemplateView |
91 | 91 | |
92 | 92 | urlpatterns = patterns('', |
… |
… |
be using these models::
|
135 | 135 | |
136 | 136 | To build a list page of all publishers, we'd use a URLconf along these lines:: |
137 | 137 | |
138 | | from django.conf.urls.defaults import * |
| 138 | from django.conf.urls import patterns, url, include |
139 | 139 | from django.views.generic import ListView |
140 | 140 | from books.models import Publisher |
141 | 141 | |
-
diff --git a/docs/topics/generic-views.txt b/docs/topics/generic-views.txt
index 9251b3a..78c3c01 100644
a
|
b
|
URLconf tuple for a given pattern.
|
58 | 58 | For example, here's a simple URLconf you could use to present a static "about" |
59 | 59 | page:: |
60 | 60 | |
61 | | from django.conf.urls.defaults import * |
| 61 | from django.conf.urls import patterns, url, include |
62 | 62 | from django.views.generic.simple import direct_to_template |
63 | 63 | |
64 | 64 | urlpatterns = patterns('', |
… |
… |
the URLconf to point to a view function:
|
80 | 80 | |
81 | 81 | .. parsed-literal:: |
82 | 82 | |
83 | | from django.conf.urls.defaults import * |
| 83 | from django.conf.urls import patterns, url, include |
84 | 84 | from django.views.generic.simple import direct_to_template |
85 | 85 | **from books.views import about_pages** |
86 | 86 | |
… |
… |
be using these models::
|
160 | 160 | |
161 | 161 | To build a list page of all publishers, we'd use a URLconf along these lines:: |
162 | 162 | |
163 | | from django.conf.urls.defaults import * |
| 163 | from django.conf.urls import patterns, url, include |
164 | 164 | from django.views.generic import list_detail |
165 | 165 | from books.models import Publisher |
166 | 166 | |
-
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index a5fb0c9..bd6a2f5 100644
a
|
b
|
algorithm the system follows to determine which Python code to execute:
|
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 :func:`django.conf.urls.defaults.patterns`. |
| 47 | the function :func:`django.conf.urls.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. |
… |
… |
Example
|
59 | 59 | |
60 | 60 | Here's a sample URLconf:: |
61 | 61 | |
62 | | from django.conf.urls.defaults import * |
| 62 | from django.conf.urls import patterns, url, include |
63 | 63 | |
64 | 64 | urlpatterns = patterns('', |
65 | 65 | (r'^articles/2003/$', 'news.views.special_case_2003'), |
… |
… |
Here's a sample URLconf::
|
70 | 70 | |
71 | 71 | Notes: |
72 | 72 | |
73 | | * ``from django.conf.urls.defaults import *`` makes the ``patterns()`` |
74 | | function available. |
75 | | |
76 | 73 | * To capture a value from the URL, just put parenthesis around it. |
77 | 74 | |
78 | 75 | * There's no need to add a leading slash, because every URL has that. For |
… |
… |
Syntax of the urlpatterns variable
|
174 | 171 | ================================== |
175 | 172 | |
176 | 173 | ``urlpatterns`` should be a Python list, in the format returned by the function |
177 | | :func:`django.conf.urls.defaults.patterns`. Always use ``patterns()`` to create |
| 174 | :func:`django.conf.urls.patterns`. Always use ``patterns()`` to create |
178 | 175 | the ``urlpatterns`` variable. |
179 | 176 | |
180 | | Convention is to use ``from django.conf.urls.defaults import *`` at the top of |
181 | | your URLconf. This gives your module access to these objects: |
| 177 | ``django.conf.urls`` also defines some other functions you'll want to use: |
182 | 178 | |
183 | 179 | .. module:: django.conf.urls.defaults |
184 | 180 | |
… |
… |
code duplication.
|
333 | 329 | |
334 | 330 | Here's the example URLconf from the :doc:`Django overview </intro/overview>`:: |
335 | 331 | |
336 | | from django.conf.urls.defaults import * |
| 332 | from django.conf.urls import patterns, url, include |
337 | 333 | |
338 | 334 | urlpatterns = patterns('', |
339 | 335 | (r'^articles/(\d{4})/$', 'news.views.year_archive'), |
… |
… |
each view function.
|
348 | 344 | |
349 | 345 | With this in mind, the above example can be written more concisely as:: |
350 | 346 | |
351 | | from django.conf.urls.defaults import * |
| 347 | from django.conf.urls import patterns, url, include |
352 | 348 | |
353 | 349 | urlpatterns = patterns('news.views', |
354 | 350 | (r'^articles/(\d{4})/$', 'year_archive'), |
… |
… |
Just add multiple ``patterns()`` objects together, like this:
|
369 | 365 | |
370 | 366 | Old:: |
371 | 367 | |
372 | | from django.conf.urls.defaults import * |
| 368 | from django.conf.urls import patterns, url, include |
373 | 369 | |
374 | 370 | urlpatterns = patterns('', |
375 | 371 | (r'^$', 'django.views.generic.date_based.archive_index'), |
… |
… |
Old::
|
379 | 375 | |
380 | 376 | New:: |
381 | 377 | |
382 | | from django.conf.urls.defaults import * |
| 378 | from django.conf.urls import patterns, url, include |
383 | 379 | |
384 | 380 | urlpatterns = patterns('django.views.generic.date_based', |
385 | 381 | (r'^$', 'archive_index'), |
… |
… |
essentially "roots" a set of URLs below other ones.
|
399 | 395 | For example, here's the URLconf for the `Django Web site`_ itself. It includes a |
400 | 396 | number of other URLconfs:: |
401 | 397 | |
402 | | from django.conf.urls.defaults import * |
| 398 | from django.conf.urls import patterns, url, include |
403 | 399 | |
404 | 400 | urlpatterns = patterns('', |
405 | 401 | (r'^weblog/', include('django_website.apps.blog.urls.blog')), |
… |
… |
Another possibility is to include additional URL patterns not by specifying the
|
417 | 413 | URLconf Python module defining them as the `include`_ argument but by using |
418 | 414 | directly the pattern list as returned by `patterns`_ instead. For example:: |
419 | 415 | |
420 | | from django.conf.urls.defaults import * |
| 416 | from django.conf.urls import patterns, url, include |
421 | 417 | |
422 | 418 | extra_patterns = patterns('', |
423 | 419 | url(r'reports/(?P<id>\d+)/$', 'credit.views.report', name='credit-reports'), |
-
diff --git a/docs/topics/http/views.txt b/docs/topics/http/views.txt
index 562be53..2e8f03d 100644
a
|
b
|
URLconf, like so::
|
145 | 145 | Behind the scenes, Django determines the 404 view by looking for ``handler404``. |
146 | 146 | By default, URLconfs contain the following line:: |
147 | 147 | |
148 | | from django.conf.urls.defaults import * |
| 148 | from django.conf.urls import patterns, url, include |
149 | 149 | |
150 | 150 | That takes care of setting ``handler404`` in the current module. As you can see |
151 | 151 | in ``django/conf/urls/defaults.py``, ``handler404`` is set to |
… |
… |
URLconf, like so::
|
195 | 195 | Behind the scenes, Django determines the error view by looking for ``handler500``. |
196 | 196 | By default, URLconfs contain the following line:: |
197 | 197 | |
198 | | from django.conf.urls.defaults import * |
| 198 | from django.conf.urls import patterns, url, include |
199 | 199 | |
200 | 200 | That takes care of setting ``handler500`` in the current module. As you can see |
201 | 201 | in ``django/conf/urls/defaults.py``, ``handler500`` is set to |
-
diff --git a/tests/modeltests/test_client/urls.py b/tests/modeltests/test_client/urls.py
index 57746d7..23e2133 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | from django.views.generic import RedirectView |
3 | 3 | import views |
4 | 4 | |
-
diff --git a/tests/regressiontests/admin_views/customadmin.py b/tests/regressiontests/admin_views/customadmin.py
index c31d379..760e93f 100644
a
|
b
|
|
1 | 1 | """ |
2 | 2 | A second, custom AdminSite -- see tests.CustomAdminSiteTests. |
3 | 3 | """ |
4 | | from django.conf.urls.defaults import patterns |
| 4 | from django.conf.urls import patterns |
5 | 5 | from django.contrib import admin |
6 | 6 | from django.http import HttpResponse |
7 | 7 | |
-
diff --git a/tests/regressiontests/admin_views/urls.py b/tests/regressiontests/admin_views/urls.py
index f3f1fbd..7320a3c 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
2 | 2 | from django.contrib import admin |
3 | 3 | import views |
4 | 4 | import customadmin |
-
diff --git a/tests/regressiontests/admin_widgets/urls.py b/tests/regressiontests/admin_widgets/urls.py
index af73d53..9e6bc12 100644
a
|
b
|
|
1 | | |
2 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
3 | 2 | import widgetadmin |
4 | 3 | |
5 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/comment_tests/urls.py b/tests/regressiontests/comment_tests/urls.py
index a2a4d09..d1a4ec0 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from django.contrib.comments.feeds import LatestCommentFeed |
3 | 3 | |
4 | 4 | feeds = { |
-
diff --git a/tests/regressiontests/comment_tests/urls_admin.py b/tests/regressiontests/comment_tests/urls_admin.py
index d7e1a4e..79a1b75 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
2 | 2 | from django.contrib import admin |
3 | 3 | from django.contrib.comments.admin import CommentsAdmin |
4 | 4 | from django.contrib.comments.models import Comment |
-
diff --git a/tests/regressiontests/conditional_processing/urls.py b/tests/regressiontests/conditional_processing/urls.py
index 8c1f465..d84030e 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | import views |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/context_processors/urls.py b/tests/regressiontests/context_processors/urls.py
index 7e8ba96..29153fa 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | |
3 | 3 | import views |
4 | 4 | |
-
diff --git a/tests/regressiontests/file_uploads/urls.py b/tests/regressiontests/file_uploads/urls.py
index 413080e..96b160e 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | import views |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/formwizard/urls.py b/tests/regressiontests/formwizard/urls.py
index d964bc6..cdac27a 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from forms import ContactWizard, Page1, Page2, Page3 |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/generic_inline_admin/urls.py b/tests/regressiontests/generic_inline_admin/urls.py
index c3e8af8..f415872 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
2 | 2 | from django.contrib import admin |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py
index 067c1f6..d0b949f 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from django.views.generic import TemplateView |
3 | 3 | from django.views.decorators.cache import cache_page |
4 | 4 | |
-
diff --git a/tests/regressiontests/middleware/extra_urls.py b/tests/regressiontests/middleware/extra_urls.py
index b2a8902..1aee48f 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import patterns |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | urlpatterns = patterns('', |
4 | 4 | (r'^middleware/customurlconf/noslash$', 'view'), |
-
diff --git a/tests/regressiontests/middleware/urls.py b/tests/regressiontests/middleware/urls.py
index 88a4b37..217e3ae 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import patterns |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | urlpatterns = patterns('', |
4 | 4 | (r'^noslash$', 'view'), |
-
diff --git a/tests/regressiontests/middleware_exceptions/urls.py b/tests/regressiontests/middleware_exceptions/urls.py
index 72c690f..ae78a65 100644
a
|
b
|
|
1 | 1 | # coding: utf-8 |
2 | | from django.conf.urls.defaults import * |
| 2 | from django.conf.urls import patterns |
3 | 3 | |
4 | 4 | import views |
5 | 5 | |
-
diff --git a/tests/regressiontests/special_headers/urls.py b/tests/regressiontests/special_headers/urls.py
index 5d223fd..db19ab9 100644
a
|
b
|
|
1 | 1 | # coding: utf-8 |
2 | | from django.conf.urls.defaults import * |
| 2 | from django.conf.urls import patterns |
3 | 3 | from django.views.generic.list_detail import object_detail |
4 | 4 | from models import Article |
5 | 5 | import views |
-
diff --git a/tests/regressiontests/syndication/urls.py b/tests/regressiontests/syndication/urls.py
index 1f7ab73..ddbc7a1 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | import feeds |
4 | 4 | |
-
diff --git a/tests/regressiontests/templates/urls.py b/tests/regressiontests/templates/urls.py
index 28d4133..96e1ea2 100644
a
|
b
|
|
1 | 1 | # coding: utf-8 |
2 | | from django.conf.urls.defaults import * |
| 2 | from django.conf.urls import patterns, url |
3 | 3 | from regressiontests.templates import views |
4 | 4 | |
5 | 5 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/test_client_regress/urls.py b/tests/regressiontests/test_client_regress/urls.py
index 121f4df..fd314e6 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from django.views.generic import RedirectView |
3 | 3 | import views |
4 | 4 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/extra_urls.py b/tests/regressiontests/urlpatterns_reverse/extra_urls.py
index c171f6d..4dbfb90 100644
a
|
b
|
|
2 | 2 | Some extra URL patterns that are included at the top level. |
3 | 3 | """ |
4 | 4 | |
5 | | from django.conf.urls.defaults import * |
| 5 | from django.conf.urls import patterns, url, include |
6 | 6 | from views import empty_view |
7 | 7 | |
8 | 8 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/included_named_urls.py b/tests/regressiontests/urlpatterns_reverse/included_named_urls.py
index b3f7903..32d2b29 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | from views import empty_view |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py b/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py
index 96c42c3..2a9779d 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from views import empty_view |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py
index 16887e2..c878f97 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | from namespace_urls import URLObject |
3 | 3 | from views import view_class_instance |
4 | 4 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/included_urls.py b/tests/regressiontests/urlpatterns_reverse/included_urls.py
index f8acf34..ae2c626 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from views import empty_view |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/included_urls2.py b/tests/regressiontests/urlpatterns_reverse/included_urls2.py
index f414ca6..b6fb4c6 100644
a
|
b
|
each name to resolve and Django must distinguish the possibilities based on the
|
5 | 5 | argument list. |
6 | 6 | """ |
7 | 7 | |
8 | | from django.conf.urls.defaults import * |
| 8 | from django.conf.urls import patterns, url |
9 | 9 | from views import empty_view |
10 | 10 | |
11 | 11 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/named_urls.py b/tests/regressiontests/urlpatterns_reverse/named_urls.py
index d8a61a1..fa71f53 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | from views import empty_view |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
index 3d34049..451bb68 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | from views import view_class_instance |
3 | 3 | |
4 | 4 | class URLObject(object): |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/no_urls.py b/tests/regressiontests/urlpatterns_reverse/no_urls.py
index c9b9efe..5b1959c 100644
a
|
b
|
|
1 | | #from django.conf.urls.defaults import * |
| 1 | #from django.conf.urls import patterns, url, include |
2 | 2 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py b/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py
index e981962..4d3fb74 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url |
2 | 2 | from django.template import Template, Context |
3 | 3 | from django.http import HttpResponse |
4 | 4 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py b/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py
index 506e036..0762fc5 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | |
3 | 3 | import urlconf_inner |
4 | 4 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urls.py b/tests/regressiontests/urlpatterns_reverse/urls.py
index c603c02..23d4af4 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, url, include |
2 | 2 | from views import empty_view, absolute_kwargs_view |
3 | 3 | |
4 | 4 | other_patterns = patterns('', |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py
index c2e0d32..7a3e220 100644
a
|
b
|
|
1 | 1 | # Used by the ErrorHandlerResolutionTests test case. |
2 | 2 | |
3 | | from django.conf.urls.defaults import patterns |
| 3 | from django.conf.urls import patterns |
4 | 4 | |
5 | 5 | urlpatterns = patterns('') |
6 | 6 | |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py
index 00f25a7..c3d4855 100644
a
|
b
|
|
1 | 1 | # Used by the ErrorHandlerResolutionTests test case. |
2 | 2 | |
3 | | from django.conf.urls.defaults import patterns |
| 3 | from django.conf.urls import patterns |
4 | 4 | from views import empty_view |
5 | 5 | |
6 | 6 | urlpatterns = patterns('') |
-
diff --git a/tests/regressiontests/urlpatterns_reverse/urls_without_full_import.py b/tests/regressiontests/urlpatterns_reverse/urls_without_full_import.py
index 75a195e..0e58a15 100644
a
|
b
|
|
1 | 1 | # A URLs file that doesn't use the default |
2 | | # from django.conf.urls.defaults import * |
| 2 | # from django.conf.urls import * |
3 | 3 | # import pattern. |
4 | | from django.conf.urls.defaults import patterns, url |
| 4 | from django.conf.urls import patterns, url |
5 | 5 | from views import empty_view, bad_view |
6 | 6 | |
7 | 7 | urlpatterns = patterns('', |
-
diff --git a/tests/regressiontests/utils/urls.py b/tests/regressiontests/utils/urls.py
index ba09d14..9e90a64 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns |
2 | 2 | |
3 | 3 | import views |
4 | 4 | |
-
diff --git a/tests/regressiontests/views/urls.py b/tests/regressiontests/views/urls.py
index 32f03b4..505dbfc 100644
a
|
b
|
|
1 | 1 | # coding: utf-8 |
2 | 2 | from os import path |
3 | 3 | |
4 | | from django.conf.urls.defaults import * |
| 4 | from django.conf.urls import patterns, url, include |
5 | 5 | |
6 | 6 | import views |
7 | 7 | |
-
diff --git a/tests/urls.py b/tests/urls.py
index 77a7578..4d34c17 100644
a
|
b
|
|
1 | | from django.conf.urls.defaults import * |
| 1 | from django.conf.urls import patterns, include |
2 | 2 | |
3 | 3 | |
4 | 4 | urlpatterns = patterns('', |