From 26b812208751edf87b4df0aee00996c5c7bcd4c9 Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Sun, 11 Sep 2011 22:36:16 +0000 Subject: [PATCH] Fixed #14675 -- Completed removal of `from django.conf.urls.default import *` usage. This applies to both our own [test] code and documentation examples. Also: * Moved the functions and handlers from `django.conf.urls.defaults` up to `django.conf.urls` deprecating the former module. * Added documentation for `handler403`. * Tweaked the URLs topic document a bit. Thanks to pupeno and cdestigter for their great work contributing patches. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16818 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/project_template/urls.py | 2 +- django/conf/urls/__init__.py | 61 +++++++++++++++++ django/conf/urls/defaults.py | 65 ++----------------- django/conf/urls/i18n.py | 2 +- django/conf/urls/shortcut.py | 2 +- django/conf/urls/static.py | 2 +- django/contrib/admin/options.py | 2 +- django/contrib/admin/sites.py | 4 +- django/contrib/admindocs/urls.py | 2 +- django/contrib/auth/admin.py | 2 +- django/contrib/auth/tests/urls.py | 2 +- django/contrib/auth/urls.py | 2 +- django/contrib/comments/urls.py | 2 +- django/contrib/databrowse/urls.py | 2 +- django/contrib/flatpages/tests/urls.py | 2 +- django/contrib/flatpages/urls.py | 2 +- django/contrib/formtools/tests/urls.py | 2 +- .../tests/wizard/namedwizardtests/urls.py | 2 +- .../tests/wizard/wizardtests/urls.py | 2 +- django/contrib/gis/tests/geoadmin/urls.py | 2 +- django/contrib/gis/tests/geoapp/urls.py | 2 +- django/contrib/messages/tests/urls.py | 2 +- django/contrib/sitemaps/tests/urls.py | 2 +- docs/internals/deprecation.txt | 6 ++ docs/intro/overview.txt | 2 +- docs/intro/tutorial02.txt | 2 +- docs/intro/tutorial03.txt | 30 ++++----- docs/intro/tutorial04.txt | 10 +-- docs/ref/contrib/admin/index.txt | 6 +- docs/ref/contrib/comments/example.txt | 4 +- docs/ref/contrib/formtools/form-wizard.txt | 6 +- docs/ref/contrib/gis/tutorial.txt | 2 +- docs/ref/contrib/sitemaps.txt | 2 +- docs/ref/contrib/syndication.txt | 4 +- docs/ref/models/instances.txt | 2 +- docs/releases/1.4.txt | 17 ++++- docs/topics/class-based-views.txt | 6 +- docs/topics/generic-views.txt | 6 +- docs/topics/http/urls.txt | 61 +++++++++++------ docs/topics/i18n/internationalization.txt | 6 +- tests/modeltests/test_client/urls.py | 2 +- .../admin_views/customadmin.py | 2 +- tests/regressiontests/admin_views/urls.py | 2 +- tests/regressiontests/admin_widgets/urls.py | 3 +- tests/regressiontests/comment_tests/urls.py | 2 +- .../comment_tests/urls_admin.py | 2 +- .../conditional_processing/urls.py | 2 +- .../context_processors/urls.py | 2 +- tests/regressiontests/file_uploads/urls.py | 2 +- .../generic_inline_admin/urls.py | 2 +- tests/regressiontests/generic_views/urls.py | 2 +- .../i18n/patterns/urls/default.py | 2 +- .../i18n/patterns/urls/disabled.py | 2 +- .../i18n/patterns/urls/namespace.py | 2 +- .../i18n/patterns/urls/wrong.py | 2 +- .../i18n/patterns/urls/wrong_namespace.py | 2 +- .../middleware/cond_get_urls.py | 2 +- .../regressiontests/middleware/extra_urls.py | 2 +- tests/regressiontests/middleware/urls.py | 2 +- .../middleware_exceptions/urls.py | 2 +- tests/regressiontests/model_permalink/urls.py | 2 +- tests/regressiontests/special_headers/urls.py | 2 +- .../staticfiles_tests/urls/default.py | 2 +- tests/regressiontests/syndication/urls.py | 2 +- .../templates/alternate_urls.py | 2 +- tests/regressiontests/templates/urls.py | 2 +- .../test_client_regress/urls.py | 2 +- tests/regressiontests/test_utils/urls.py | 2 +- .../urlpatterns_reverse/erroneous_urls.py | 2 +- .../urlpatterns_reverse/extra_urls.py | 2 +- .../included_named_urls.py | 2 +- .../included_named_urls2.py | 2 +- .../included_namespace_urls.py | 2 +- .../urlpatterns_reverse/included_urls.py | 2 +- .../urlpatterns_reverse/included_urls2.py | 2 +- .../urlpatterns_reverse/named_urls.py | 2 +- .../urlpatterns_reverse/namespace_urls.py | 2 +- .../urlpatterns_reverse/no_urls.py | 2 +- .../urlpatterns_reverse/reverse_lazy_urls.py | 2 +- .../urlpatterns_reverse/urlconf_inner.py | 2 +- .../urlpatterns_reverse/urlconf_outer.py | 2 +- .../urlpatterns_reverse/urls.py | 2 +- .../urls_error_handlers.py | 2 +- .../urls_error_handlers_callables.py | 2 +- .../urls_without_full_import.py | 4 +- tests/regressiontests/views/generic_urls.py | 2 +- tests/regressiontests/views/urls.py | 2 +- tests/urls.py | 2 +- 88 files changed, 243 insertions(+), 198 deletions(-) diff --git a/django/conf/project_template/urls.py b/django/conf/project_template/urls.py index 0ce1ffb98d..eb471d54a8 100644 --- a/django/conf/project_template/urls.py +++ b/django/conf/project_template/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, include, url +from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: # from django.contrib import admin diff --git a/django/conf/urls/__init__.py b/django/conf/urls/__init__.py index e69de29bb2..0b6ab6496e 100644 --- a/django/conf/urls/__init__.py +++ b/django/conf/urls/__init__.py @@ -0,0 +1,61 @@ +from django.core.urlresolvers import (RegexURLPattern, + RegexURLResolver, LocaleRegexURLResolver) +from django.core.exceptions import ImproperlyConfigured +from django.utils.importlib import import_module + + +__all__ = ['handler403', 'handler404', 'handler500', 'include', 'patterns', 'url'] + +handler403 = 'django.views.defaults.permission_denied' +handler404 = 'django.views.defaults.page_not_found' +handler500 = 'django.views.defaults.server_error' + +def include(arg, namespace=None, app_name=None): + if isinstance(arg, tuple): + # callable returning a namespace hint + if namespace: + raise ImproperlyConfigured('Cannot override the namespace for a dynamic module that provides a namespace') + urlconf_module, app_name, namespace = arg + else: + # No namespace hint - use manually provided namespace + urlconf_module = arg + + if isinstance(urlconf_module, basestring): + urlconf_module = import_module(urlconf_module) + patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module) + + # Make sure we can iterate through the patterns (without this, some + # testcases will break). + if isinstance(patterns, (list, tuple)): + for url_pattern in patterns: + # Test if the LocaleRegexURLResolver is used within the include; + # this should throw an error since this is not allowed! + if isinstance(url_pattern, LocaleRegexURLResolver): + raise ImproperlyConfigured( + 'Using i18n_patterns in an included URLconf is not allowed.') + + return (urlconf_module, app_name, namespace) + +def patterns(prefix, *args): + pattern_list = [] + for t in args: + if isinstance(t, (list, tuple)): + t = url(prefix=prefix, *t) + elif isinstance(t, RegexURLPattern): + t.add_prefix(prefix) + pattern_list.append(t) + return pattern_list + +def url(regex, view, kwargs=None, name=None, prefix=''): + if isinstance(view, (list,tuple)): + # For include(...) processing. + urlconf_module, app_name, namespace = view + return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace) + else: + if isinstance(view, basestring): + if not view: + raise ImproperlyConfigured('Empty URL pattern view name not permitted (for pattern %r)' % regex) + if prefix: + view = prefix + '.' + view + return RegexURLPattern(regex, view, kwargs, name) + diff --git a/django/conf/urls/defaults.py b/django/conf/urls/defaults.py index 19f4230097..326f05f4ba 100644 --- a/django/conf/urls/defaults.py +++ b/django/conf/urls/defaults.py @@ -1,61 +1,6 @@ -from django.core.urlresolvers import (RegexURLPattern, - RegexURLResolver, LocaleRegexURLResolver) -from django.core.exceptions import ImproperlyConfigured -from django.utils.importlib import import_module - - -__all__ = ['handler404', 'handler500', 'include', 'patterns', 'url'] - -handler403 = 'django.views.defaults.permission_denied' -handler404 = 'django.views.defaults.page_not_found' -handler500 = 'django.views.defaults.server_error' - -def include(arg, namespace=None, app_name=None): - if isinstance(arg, tuple): - # callable returning a namespace hint - if namespace: - raise ImproperlyConfigured('Cannot override the namespace for a dynamic module that provides a namespace') - urlconf_module, app_name, namespace = arg - else: - # No namespace hint - use manually provided namespace - urlconf_module = arg - - if isinstance(urlconf_module, basestring): - urlconf_module = import_module(urlconf_module) - patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module) - - # Make sure we can iterate through the patterns (without this, some - # testcases will break). - if isinstance(patterns, (list, tuple)): - for url_pattern in patterns: - # Test if the LocaleRegexURLResolver is used within the include; - # this should throw an error since this is not allowed! - if isinstance(url_pattern, LocaleRegexURLResolver): - raise ImproperlyConfigured( - 'Using i18n_patterns in an included URLconf is not allowed.') - - return (urlconf_module, app_name, namespace) - -def patterns(prefix, *args): - pattern_list = [] - for t in args: - if isinstance(t, (list, tuple)): - t = url(prefix=prefix, *t) - elif isinstance(t, RegexURLPattern): - t.add_prefix(prefix) - pattern_list.append(t) - return pattern_list - -def url(regex, view, kwargs=None, name=None, prefix=''): - if isinstance(view, (list,tuple)): - # For include(...) processing. - urlconf_module, app_name, namespace = view - return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace) - else: - if isinstance(view, basestring): - if not view: - raise ImproperlyConfigured('Empty URL pattern view name not permitted (for pattern %r)' % regex) - if prefix: - view = prefix + '.' + view - return RegexURLPattern(regex, view, kwargs, name) +import warnings +warnings.warn("django.conf.urls.defaults is deprecated; use django.conf.urls instead", + PendingDeprecationWarning) +from django.conf.urls import (handler403, handler404, handler500, + include, patterns, url) diff --git a/django/conf/urls/i18n.py b/django/conf/urls/i18n.py index 67931aaf1c..6e56af8271 100644 --- a/django/conf/urls/i18n.py +++ b/django/conf/urls/i18n.py @@ -1,5 +1,5 @@ from django.conf import settings -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns from django.core.urlresolvers import LocaleRegexURLResolver def i18n_patterns(prefix, *args): diff --git a/django/conf/urls/shortcut.py b/django/conf/urls/shortcut.py index 135f3be840..6eb2e55e68 100644 --- a/django/conf/urls/shortcut.py +++ b/django/conf/urls/shortcut.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns urlpatterns = patterns('django.views', (r'^(?P\d+)/(?P.*)/$', 'defaults.shortcut'), diff --git a/django/conf/urls/static.py b/django/conf/urls/static.py index 8be564ec7a..8d305653bd 100644 --- a/django/conf/urls/static.py +++ b/django/conf/urls/static.py @@ -1,6 +1,6 @@ import re from django.conf import settings -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from django.core.exceptions import ImproperlyConfigured def static(prefix, view='django.views.static.serve', **kwargs): diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index c9f2562142..5271e021ef 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -320,7 +320,7 @@ class ModelAdmin(BaseModelAdmin): super(ModelAdmin, self).__init__() def get_urls(self): - from django.conf.urls.defaults import patterns, url + from django.conf.urls import patterns, url def wrap(view): def wrapper(*args, **kwargs): diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 49c1e7878c..9bb9f4ab46 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -174,7 +174,7 @@ class AdminSite(object): class MyAdminSite(AdminSite): def get_urls(self): - from django.conf.urls.defaults import patterns, url + from django.conf.urls import patterns, url urls = super(MyAdminSite, self).get_urls() urls += patterns('', @@ -199,7 +199,7 @@ class AdminSite(object): return update_wrapper(inner, view) def get_urls(self): - from django.conf.urls.defaults import patterns, url, include + from django.conf.urls import patterns, url, include if settings.DEBUG: self.check_dependencies() diff --git a/django/contrib/admindocs/urls.py b/django/contrib/admindocs/urls.py index 57edb5697b..4f50049f87 100644 --- a/django/contrib/admindocs/urls.py +++ b/django/contrib/admindocs/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.contrib.admindocs import views urlpatterns = patterns('', diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 9bfc036f26..3868794fed 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -74,7 +74,7 @@ class UserAdmin(admin.ModelAdmin): return super(UserAdmin, self).get_form(request, obj, **defaults) def get_urls(self): - from django.conf.urls.defaults import patterns + from django.conf.urls import patterns return patterns('', (r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password)) ) + super(UserAdmin, self).get_urls() diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py index 4445a9c014..dbbd35ee88 100644 --- a/django/contrib/auth/tests/urls.py +++ b/django/contrib/auth/tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from django.contrib.auth import context_processors from django.contrib.auth.urls import urlpatterns from django.contrib.auth.views import password_reset diff --git a/django/contrib/auth/urls.py b/django/contrib/auth/urls.py index 42b4e8f212..71061531f1 100644 --- a/django/contrib/auth/urls.py +++ b/django/contrib/auth/urls.py @@ -2,7 +2,7 @@ # provided as a convenience to those who want to deploy these URLs elsewhere. # This file is also used to provide a reliable view deployment for test purposes. -from django.conf.urls.defaults import * +from django.conf.urls import patterns urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), diff --git a/django/contrib/comments/urls.py b/django/contrib/comments/urls.py index d9037799dd..69a022288b 100644 --- a/django/contrib/comments/urls.py +++ b/django/contrib/comments/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns('django.contrib.comments.views', 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 9b85d142a2..5c431deb21 100644 --- a/django/contrib/databrowse/urls.py +++ b/django/contrib/databrowse/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns from django.contrib.databrowse import views # 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 3cffd09d0f..e0e7a074b0 100644 --- a/django/contrib/flatpages/tests/urls.py +++ b/django/contrib/flatpages/tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include # special urls for flatpage test cases urlpatterns = patterns('', diff --git a/django/contrib/flatpages/urls.py b/django/contrib/flatpages/urls.py index 49289304ff..5abb8e1986 100644 --- a/django/contrib/flatpages/urls.py +++ b/django/contrib/flatpages/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns urlpatterns = patterns('django.contrib.flatpages.views', (r'^(?P.*)$', 'flatpage'), diff --git a/django/contrib/formtools/tests/urls.py b/django/contrib/formtools/tests/urls.py index f058335b07..313a53413b 100644 --- a/django/contrib/formtools/tests/urls.py +++ b/django/contrib/formtools/tests/urls.py @@ -2,7 +2,7 @@ This is a URLconf to be loaded by tests.py. Add any URLs needed for tests only. """ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.contrib.formtools.tests import TestFormPreview, TestWizardClass from forms import (ContactWizard, Page1, Page2, Page3, TestForm, diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py index 04019d127f..ac2cadc321 100644 --- a/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py +++ b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from django.contrib.formtools.tests.wizard.namedwizardtests.forms import ( SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4) diff --git a/django/contrib/formtools/tests/wizard/wizardtests/urls.py b/django/contrib/formtools/tests/wizard/wizardtests/urls.py index e6d18ea5d1..dabce5306a 100644 --- a/django/contrib/formtools/tests/wizard/wizardtests/urls.py +++ b/django/contrib/formtools/tests/wizard/wizardtests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.contrib.formtools.tests.wizard.wizardtests.forms import ( SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4) diff --git a/django/contrib/gis/tests/geoadmin/urls.py b/django/contrib/gis/tests/geoadmin/urls.py index c3e8af8fe1..f41587280d 100644 --- a/django/contrib/gis/tests/geoadmin/urls.py +++ b/django/contrib/gis/tests/geoadmin/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include from django.contrib import admin urlpatterns = patterns('', diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py index b3604c7aa0..2725d98d9d 100644 --- a/django/contrib/gis/tests/geoapp/urls.py +++ b/django/contrib/gis/tests/geoapp/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns from feeds import feed_dict urlpatterns = patterns('', diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py index 263b0a8a0d..6d32a614eb 100644 --- a/django/contrib/messages/tests/urls.py +++ b/django/contrib/messages/tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns from django.contrib import messages from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponse diff --git a/django/contrib/sitemaps/tests/urls.py b/django/contrib/sitemaps/tests/urls.py index 03b060df7a..c264f940d2 100644 --- a/django/contrib/sitemaps/tests/urls.py +++ b/django/contrib/sitemaps/tests/urls.py @@ -1,5 +1,5 @@ from datetime import datetime -from django.conf.urls.defaults import * +from django.conf.urls import patterns from django.contrib.sitemaps import Sitemap, GenericSitemap, FlatPageSitemap from django.contrib.auth.models import User diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 88354e1b41..09966c247b 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -243,6 +243,12 @@ their deprecation, as per the :ref:`deprecation policy :mod:`django.contrib.gis.geoip` in 1.4 -- the shortcut in :mod:`django.contrib.gis.utils` will be removed. + * In 1.4, functions :func:`~django.conf.urls.include`, :func:`~django.conf.urls.patterns` + and :func:`~django.conf.urls.url` plus :data:`~django.conf.urls.handler404`, + :data:`~django.conf.urls.handler500` were moved to :mod:`django.conf.urls` + from their previous location ``django.conf.urls.defaults``. This module + was deprecated at the same time and will be removed in this Django release. + 2.0 --- diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt index 34572a6c80..737db21866 100644 --- a/docs/intro/overview.txt +++ b/docs/intro/overview.txt @@ -176,7 +176,7 @@ decouple URLs from Python code. Here's what a URLconf might look like for the ``Reporter``/``Article`` example above:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('', (r'^articles/(\d{4})/$', 'news.views.year_archive'), diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index 2c625a73a5..589e11f617 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -40,7 +40,7 @@ activate the admin site for your installation, do these three things: .. parsed-literal:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: **from django.contrib import admin** diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 82cf60b118..a489a77930 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -78,7 +78,7 @@ point at that file:: Time for an example. Edit ``mysite/urls.py`` so it looks like this:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() @@ -367,7 +367,7 @@ special: It's just a normal view. You normally won't have to bother with writing 404 views. By default, URLconfs have the following line up top:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url That takes care of setting ``handler404`` in the current module. As you can see in ``django/conf/urls/defaults.py``, ``handler404`` is set to @@ -443,7 +443,7 @@ Namely, ``polls.views`` is in every callback. Because this is a common case, the URLconf framework provides a shortcut for common prefixes. You can factor out the common prefixes and add them as the -first argument to :func:`~django.conf.urls.defaults.patterns`, like so:: +first argument to :func:`~django.conf.urls.patterns`, like so:: urlpatterns = patterns('polls.views', (r'^polls/$', 'index'), @@ -457,21 +457,21 @@ tidier. Since you generally don't want the prefix for one app to be applied to every callback in your URLconf, you can concatenate multiple -:func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might +:func:`~django.conf.urls.patterns`. Your full ``mysite/urls.py`` might now look like this:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() - + urlpatterns = patterns('polls.views', (r'^polls/$', 'index'), (r'^polls/(?P\d+)/$', 'detail'), (r'^polls/(?P\d+)/results/$', 'results'), (r'^polls/(?P\d+)/vote/$', 'vote'), ) - + urlpatterns += patterns('', url(r'^admin/', include(admin.site.urls)), ) @@ -494,23 +494,23 @@ URLs within the app directory. Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change ``mysite/urls.py`` to remove the poll-specific URLs and insert an -:func:`~django.conf.urls.defaults.include`, leaving you with:: +:func:`~django.conf.urls.include`, leaving you with:: # This also imports the include function - from django.conf.urls.defaults import patterns, include, url - + from django.conf.urls import patterns, include, url + from django.contrib import admin admin.autodiscover() - + urlpatterns = patterns('', (r'^polls/', include('polls.urls')), url(r'^admin/', include(admin.site.urls)), ) -:func:`~django.conf.urls.defaults.include` simply references another URLconf. +:func:`~django.conf.urls.include` simply references another URLconf. Note that the regular expression doesn't have a ``$`` (end-of-string match character) but has the trailing slash. Whenever Django encounters -:func:`~django.conf.urls.defaults.include`, it chops off whatever part of the +:func:`~django.conf.urls.include`, it chops off whatever part of the URL matched up to that point and sends the remaining string to the included URLconf for further processing. @@ -527,7 +527,7 @@ URLconf by removing the leading "polls/" from each line, and removing the lines registering the admin site. Your ``polls/urls.py`` file should now look like this:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url urlpatterns = patterns('polls.views', (r'^$', 'index'), @@ -536,7 +536,7 @@ this:: (r'^(?P\d+)/vote/$', 'vote'), ) -The idea behind :func:`~django.conf.urls.defaults.include` and URLconf +The idea behind :func:`~django.conf.urls.include` and URLconf decoupling is to make it easy to plug-and-play URLs. Now that polls are in their own URLconf, they can be placed under "/polls/", or under "/fun_polls/", or under "/content/polls/", or any other path root, and the app will still work. diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index 86d4eef9b7..f0d2abc191 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -218,7 +218,7 @@ Read on for details. First, open the ``polls/urls.py`` URLconf. It looks like this, according to the tutorial so far:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url urlpatterns = patterns('polls.views', (r'^$', 'index'), @@ -229,7 +229,7 @@ tutorial so far:: Change it like so:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url from django.views.generic import DetailView, ListView from polls.models import Poll @@ -269,9 +269,9 @@ two views abstract the concepts of "display a list of objects" and that we have a way to refer to its URL later on (see the documentation about :ref:`naming URL patterns ` for information). We're also using the - :func:`~django.conf.urls.default.url` function from - :mod:`django.conf.urls.defaults` here. It's a good habit to use - :func:`~django.conf.urls.defaults.url` when you are providing a + :func:`~django.conf.urls.url` function from + :mod:`django.conf.urls` here. It's a good habit to use + :func:`~django.conf.urls.url` when you are providing a pattern name like this. By default, the :class:`~django.views.generic.list.DetailView` generic diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index e280463f8c..bdbe61505d 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1831,7 +1831,7 @@ In this example, we register the default ``AdminSite`` instance ``django.contrib.admin.site`` at the URL ``/admin/`` :: # urls.py - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.contrib import admin admin.autodiscover() @@ -1847,7 +1847,7 @@ In this example, we register the ``AdminSite`` instance ``myproject.admin.admin_site`` at the URL ``/myadmin/`` :: # urls.py - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from myproject.admin import admin_site urlpatterns = patterns('', @@ -1871,7 +1871,7 @@ separate versions of the admin site -- using the ``AdminSite`` instances respectively:: # urls.py - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from myproject.admin import basic_site, advanced_site urlpatterns = patterns('', diff --git a/docs/ref/contrib/comments/example.txt b/docs/ref/contrib/comments/example.txt index 253701b8da..82ae08e66d 100644 --- a/docs/ref/contrib/comments/example.txt +++ b/docs/ref/contrib/comments/example.txt @@ -143,7 +143,7 @@ enable it in your project's ``urls.py``: .. code-block:: python - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.contrib.comments.feeds import LatestCommentFeed urlpatterns = patterns('', @@ -161,7 +161,7 @@ syndication feed view: .. code-block:: python - from django.conf.urls.defaults import * + from django.conf.urls import patterns from django.contrib.comments.feeds import LatestCommentFeed feeds = { diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt index 2645c28a32..24f81e244d 100644 --- a/docs/ref/contrib/formtools/form-wizard.txt +++ b/docs/ref/contrib/formtools/form-wizard.txt @@ -217,7 +217,7 @@ deploy the new :class:`WizardView` object a URL in the ``urls.py``. The wizard's :meth:`as_view` method takes a list of your :class:`~django.forms.Form` classes as an argument during instantiation:: - from django.conf.urls.defaults import patterns + from django.conf.urls import patterns from myapp.forms import ContactForm1, ContactForm2 from myapp.views import ContactWizard @@ -525,7 +525,7 @@ We define our wizard in a ``views.py``:: We need to add the ``ContactWizard`` to our ``urls.py`` file:: - from django.conf.urls.defaults import pattern + from django.conf.urls import pattern from myapp.forms import ContactForm1, ContactForm2 from myapp.views import ContactWizard, show_message_form_condition @@ -572,7 +572,7 @@ Additionally you have to pass two more arguments to the Example code for the changed ``urls.py`` file:: - from django.conf.urls.defaults import url, patterns + from django.conf.urls import url, patterns from myapp.forms import ContactForm1, ContactForm2 from myapp.views import ContactWizard diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt index bf6a037097..5138c4092a 100644 --- a/docs/ref/contrib/gis/tutorial.txt +++ b/docs/ref/contrib/gis/tutorial.txt @@ -697,7 +697,7 @@ Let's dive in again -- create a file called ``admin.py`` inside the Next, edit your ``urls.py`` in the ``geodjango`` project folder to look as follows:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.contrib.gis import admin admin.autodiscover() diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt index 300c142f0b..ecc5024877 100644 --- a/docs/ref/contrib/sitemaps.txt +++ b/docs/ref/contrib/sitemaps.txt @@ -241,7 +241,7 @@ Example Here's an example of a :doc:`URLconf ` using both:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap from blog.models import Entry diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt index 398f6ca4cb..bbc58cef55 100644 --- a/docs/ref/contrib/syndication.txt +++ b/docs/ref/contrib/syndication.txt @@ -80,7 +80,7 @@ latest five news items:: To connect a URL to this feed, put an instance of the Feed object in your :doc:`URLconf `. For example:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from myproject.feeds import LatestEntriesFeed urlpatterns = patterns('', @@ -327,7 +327,7 @@ Here's a full example:: And the accompanying URLconf:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from myproject.feeds import RssSiteNewsFeed, AtomSiteNewsFeed urlpatterns = patterns('', diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 8809eaf86a..4ab9dd3011 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -524,7 +524,7 @@ pattern, it's possible to give a name to a pattern, and then reference the name rather than the view function. A named URL pattern is defined by replacing the pattern tuple by a call to the ``url`` function):: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include url(r'^people/(\d+)/$', 'blog_views.generic_detail', name='people_view'), diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index f078ee0dfd..94c1721992 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -290,9 +290,10 @@ Django 1.4 also includes several smaller improvements worth noting: MySQL with the InnoDB database engine. * A new 403 response handler has been added as - ``'django.views.defaults.permission_denied'``. See the documentation - about :ref:`the 403 (HTTP Forbidden) view` for more - information. + ``'django.views.defaults.permission_denied'``. You can set your own handler by + setting the value of :data:`django.conf.urls.handler403`. See the + documentation about :ref:`the 403 (HTTP Forbidden) view` + for more information. * The :ttag:`trans` template tag now takes an optional ``as`` argument to be able to retrieve a translation string without displaying it but setting @@ -590,3 +591,13 @@ backwards-compatibility shim will be removed entirely. The existence of any ``'filters'`` key under the ``'mail_admins'`` handler will disable this backward-compatibility shim and deprecation warning. + +``django.conf.urls.defaults`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Until Django 1.3 the functions :func:`~django.conf.urls.include`, +:func:`~django.conf.urls.patterns` and :func:`~django.conf.urls.url` plus +:data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500` +were located in a ``django.conf.urls.defaults`` module. + +Starting with Django 1.4 they are now available in :mod:`django.conf.urls`. diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt index 8092cb29af..62368faee1 100644 --- a/docs/topics/class-based-views.txt +++ b/docs/topics/class-based-views.txt @@ -75,7 +75,7 @@ views themselves are classes, we point the URL to the ``as_view`` class method instead, which is the entry point for class-based views:: # urls.py - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from some_app.views import AboutView urlpatterns = patterns('', @@ -86,7 +86,7 @@ Alternatively, if you're only changing a few simple attributes on a class-based view, you can simply pass the new attributes into the ``as_view`` method call itself:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.views.generic import TemplateView urlpatterns = patterns('', @@ -135,7 +135,7 @@ be using these models:: To build a list page of all publishers, we'd use a URLconf along these lines:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.views.generic import ListView from books.models import Publisher diff --git a/docs/topics/generic-views.txt b/docs/topics/generic-views.txt index 9251b3ad44..78c3c0199f 100644 --- a/docs/topics/generic-views.txt +++ b/docs/topics/generic-views.txt @@ -58,7 +58,7 @@ URLconf tuple for a given pattern. For example, here's a simple URLconf you could use to present a static "about" page:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.views.generic.simple import direct_to_template urlpatterns = patterns('', @@ -80,7 +80,7 @@ the URLconf to point to a view function: .. parsed-literal:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.views.generic.simple import direct_to_template **from books.views import about_pages** @@ -160,7 +160,7 @@ be using these models:: To build a list page of all publishers, we'd use a URLconf along these lines:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include from django.views.generic import list_detail from books.models import Publisher diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index c1a15ab229..18789b3f25 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -50,7 +50,7 @@ algorithm the system follows to determine which Python code to execute: 2. Django loads that Python module and looks for the variable ``urlpatterns``. This should be a Python list, in the format returned by - the function :func:`django.conf.urls.defaults.patterns`. + the function :func:`django.conf.urls.patterns`. 3. Django runs through each URL pattern, in order, and stops at the first one that matches the requested URL. @@ -69,7 +69,7 @@ Example Here's a sample URLconf:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('', (r'^articles/2003/$', 'news.views.special_case_2003'), @@ -80,9 +80,6 @@ Here's a sample URLconf:: Notes: - * ``from django.conf.urls.defaults import *`` makes the ``patterns()`` - function available. - * To capture a value from the URL, just put parenthesis around it. * There's no need to add a leading slash, because every URL has that. For @@ -184,13 +181,21 @@ Syntax of the urlpatterns variable ================================== ``urlpatterns`` should be a Python list, in the format returned by the function -:func:`django.conf.urls.defaults.patterns`. Always use ``patterns()`` to create +:func:`django.conf.urls.patterns`. Always use ``patterns()`` to create the ``urlpatterns`` variable. -Convention is to use ``from django.conf.urls.defaults import *`` at the top of -your URLconf. This gives your module access to these objects: +``django.conf.urls`` utility functions +====================================== -.. module:: django.conf.urls.defaults +.. module:: django.conf.urls + +.. deprecated:: 1.4 + Starting with Django 1.4 functions ``patterns``, ``url``, ``include`` plus + the ``handler*`` symbols described below live in the ``django.conf.urls`` + module. + + Until Django 1.3 they were located in ``django.conf.urls.defaults``. You + still can import them from there but it will be removed in Django 1.6. patterns -------- @@ -281,6 +286,24 @@ URLconf will have no effect. See the documentation on :ref:`customizing error views ` for more details. +handler403 +---------- + +.. data:: handler403 + +A callable, or a string representing the full Python import path to the view +that should be called if the user has no the permissions required to access +a resource. + +By default, this is ``'django.views.defaults.permission_denied'``. That default +value should suffice. + +See the documentation about :ref:`the 403 (HTTP Forbidden) view +` for more information. + +.. versionadded:: 1.4 + ``handler403`` is new in Django 1.4. + handler404 ---------- @@ -355,7 +378,7 @@ code duplication. Here's the example URLconf from the :doc:`Django overview `:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('', (r'^articles/(\d{4})/$', 'news.views.year_archive'), @@ -370,7 +393,7 @@ each view function. With this in mind, the above example can be written more concisely as:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('news.views', (r'^articles/(\d{4})/$', 'year_archive'), @@ -391,7 +414,7 @@ Just add multiple ``patterns()`` objects together, like this: Old:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('', (r'^$', 'django.views.generic.date_based.archive_index'), @@ -401,7 +424,7 @@ Old:: New:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('django.views.generic.date_based', (r'^$', 'archive_index'), @@ -421,7 +444,7 @@ essentially "roots" a set of URLs below other ones. For example, here's the URLconf for the `Django Web site`_ itself. It includes a number of other URLconfs:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include urlpatterns = patterns('', (r'^weblog/', include('django_website.apps.blog.urls.blog')), @@ -439,7 +462,7 @@ Another possibility is to include additional URL patterns not by specifying the URLconf Python module defining them as the `include`_ argument but by using directly the pattern list as returned by `patterns`_ instead. For example:: - from django.conf.urls.defaults import * + from django.conf.urls import patterns, url, include extra_patterns = patterns('', url(r'reports/(?P\d+)/$', 'credit.views.report', name='credit-reports'), @@ -784,8 +807,8 @@ following would happen: * ``foo:index`` will again resolve to the index page of the instance ``foo``. -Utility methods -=============== +``django.core.urlresolvers`` utility functions +============================================== .. currentmodule:: django.core.urlresolvers @@ -793,7 +816,7 @@ reverse() --------- If you need to use something similar to the :ttag:`url` template tag in -your code, Django provides the following method (in the +your code, Django provides the following function (in the :mod:`django.core.urlresolvers` module): .. function:: reverse(viewname, [urlconf=None, args=None, kwargs=None, current_app=None]) @@ -859,7 +882,7 @@ reverse_lazy() A lazily evaluated version of `reverse()`_. It is useful for when you need to use a URL reversal before your project's -URLConf is loaded. Some common cases where this method is necessary are: +URLConf is loaded. Some common cases where this function is necessary are: * providing a reversed URL as the ``url`` attribute of a generic class-based view. diff --git a/docs/topics/i18n/internationalization.txt b/docs/topics/i18n/internationalization.txt index dbeb77c879..744509638d 100644 --- a/docs/topics/i18n/internationalization.txt +++ b/docs/topics/i18n/internationalization.txt @@ -819,11 +819,11 @@ Language prefix in URL patterns .. function:: i18n_patterns(prefix, pattern_description, ...) This function can be used in your root URLconf as a replacement for the normal -:func:`django.conf.urls.defaults.patterns` function. Django will automatically +:func:`django.conf.urls.patterns` function. Django will automatically prepend the current active language code to all url patterns defined within :func:`~django.conf.urls.i18n.i18n_patterns`. Example URL patterns:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url from django.conf.urls.i18n import i18n_patterns urlpatterns = patterns('' @@ -877,7 +877,7 @@ Translating URL patterns URL patterns can also be marked translatable using the :func:`~django.utils.translation.ugettext_lazy` function. Example:: - from django.conf.urls.defaults import patterns, include, url + from django.conf.urls import patterns, include, url from django.conf.urls.i18n import i18n_patterns from django.utils.translation import ugettext_lazy as _ diff --git a/tests/modeltests/test_client/urls.py b/tests/modeltests/test_client/urls.py index 66019498e6..6a2d0a96c1 100644 --- a/tests/modeltests/test_client/urls.py +++ b/tests/modeltests/test_client/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns from django.views.generic import RedirectView import views diff --git a/tests/regressiontests/admin_views/customadmin.py b/tests/regressiontests/admin_views/customadmin.py index c31d3794cd..760e93f0f8 100644 --- a/tests/regressiontests/admin_views/customadmin.py +++ b/tests/regressiontests/admin_views/customadmin.py @@ -1,7 +1,7 @@ """ A second, custom AdminSite -- see tests.CustomAdminSiteTests. """ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns from django.contrib import admin from django.http import HttpResponse diff --git a/tests/regressiontests/admin_views/urls.py b/tests/regressiontests/admin_views/urls.py index f3f1fbd43a..7320a3c7c8 100644 --- a/tests/regressiontests/admin_views/urls.py +++ b/tests/regressiontests/admin_views/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include from django.contrib import admin import views import customadmin diff --git a/tests/regressiontests/admin_widgets/urls.py b/tests/regressiontests/admin_widgets/urls.py index af73d5351d..9e6bc1290f 100644 --- a/tests/regressiontests/admin_widgets/urls.py +++ b/tests/regressiontests/admin_widgets/urls.py @@ -1,5 +1,4 @@ - -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include import widgetadmin urlpatterns = patterns('', diff --git a/tests/regressiontests/comment_tests/urls.py b/tests/regressiontests/comment_tests/urls.py index a2a4d09c64..d1a4ec01c2 100644 --- a/tests/regressiontests/comment_tests/urls.py +++ b/tests/regressiontests/comment_tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.contrib.comments.feeds import LatestCommentFeed feeds = { diff --git a/tests/regressiontests/comment_tests/urls_admin.py b/tests/regressiontests/comment_tests/urls_admin.py index d7e1a4e916..79a1b75451 100644 --- a/tests/regressiontests/comment_tests/urls_admin.py +++ b/tests/regressiontests/comment_tests/urls_admin.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include from django.contrib import admin from django.contrib.comments.admin import CommentsAdmin from django.contrib.comments.models import Comment diff --git a/tests/regressiontests/conditional_processing/urls.py b/tests/regressiontests/conditional_processing/urls.py index 8c1f465464..d84030e393 100644 --- a/tests/regressiontests/conditional_processing/urls.py +++ b/tests/regressiontests/conditional_processing/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns import views urlpatterns = patterns('', diff --git a/tests/regressiontests/context_processors/urls.py b/tests/regressiontests/context_processors/urls.py index 7e8ba967c1..29153fadf2 100644 --- a/tests/regressiontests/context_processors/urls.py +++ b/tests/regressiontests/context_processors/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url import views diff --git a/tests/regressiontests/file_uploads/urls.py b/tests/regressiontests/file_uploads/urls.py index a5c2702311..904f28bad9 100644 --- a/tests/regressiontests/file_uploads/urls.py +++ b/tests/regressiontests/file_uploads/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns import views urlpatterns = patterns('', diff --git a/tests/regressiontests/generic_inline_admin/urls.py b/tests/regressiontests/generic_inline_admin/urls.py index c3e8af8fe1..f41587280d 100644 --- a/tests/regressiontests/generic_inline_admin/urls.py +++ b/tests/regressiontests/generic_inline_admin/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include from django.contrib import admin urlpatterns = patterns('', diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py index 0f844e0243..0f725d8fde 100644 --- a/tests/regressiontests/generic_views/urls.py +++ b/tests/regressiontests/generic_views/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.views.generic import TemplateView from django.views.decorators.cache import cache_page diff --git a/tests/regressiontests/i18n/patterns/urls/default.py b/tests/regressiontests/i18n/patterns/urls/default.py index 8d178e67d4..f117502753 100644 --- a/tests/regressiontests/i18n/patterns/urls/default.py +++ b/tests/regressiontests/i18n/patterns/urls/default.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, include, url +from django.conf.urls import patterns, include, url from django.conf.urls.i18n import i18n_patterns from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView diff --git a/tests/regressiontests/i18n/patterns/urls/disabled.py b/tests/regressiontests/i18n/patterns/urls/disabled.py index e4094695f9..60fd222024 100644 --- a/tests/regressiontests/i18n/patterns/urls/disabled.py +++ b/tests/regressiontests/i18n/patterns/urls/disabled.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import url +from django.conf.urls import url from django.conf.urls.i18n import i18n_patterns from django.views.generic import TemplateView diff --git a/tests/regressiontests/i18n/patterns/urls/namespace.py b/tests/regressiontests/i18n/patterns/urls/namespace.py index 0e703405cb..bf43949961 100644 --- a/tests/regressiontests/i18n/patterns/urls/namespace.py +++ b/tests/regressiontests/i18n/patterns/urls/namespace.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView diff --git a/tests/regressiontests/i18n/patterns/urls/wrong.py b/tests/regressiontests/i18n/patterns/urls/wrong.py index 40302fc98f..22e9d535cc 100644 --- a/tests/regressiontests/i18n/patterns/urls/wrong.py +++ b/tests/regressiontests/i18n/patterns/urls/wrong.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import include, url +from django.conf.urls import include, url from django.conf.urls.i18n import i18n_patterns from django.utils.translation import ugettext_lazy as _ diff --git a/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py b/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py index 46ecfd0e7a..2f7105d637 100644 --- a/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py +++ b/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import url +from django.conf.urls import url from django.conf.urls.i18n import i18n_patterns from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView diff --git a/tests/regressiontests/middleware/cond_get_urls.py b/tests/regressiontests/middleware/cond_get_urls.py index 2c2a8f8278..1dadd0d31a 100644 --- a/tests/regressiontests/middleware/cond_get_urls.py +++ b/tests/regressiontests/middleware/cond_get_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns from django.http import HttpResponse urlpatterns = patterns('', diff --git a/tests/regressiontests/middleware/extra_urls.py b/tests/regressiontests/middleware/extra_urls.py index b2a89023d5..1aee48f7be 100644 --- a/tests/regressiontests/middleware/extra_urls.py +++ b/tests/regressiontests/middleware/extra_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns urlpatterns = patterns('', (r'^middleware/customurlconf/noslash$', 'view'), diff --git a/tests/regressiontests/middleware/urls.py b/tests/regressiontests/middleware/urls.py index 88a4b37ddc..217e3ae034 100644 --- a/tests/regressiontests/middleware/urls.py +++ b/tests/regressiontests/middleware/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns urlpatterns = patterns('', (r'^noslash$', 'view'), diff --git a/tests/regressiontests/middleware_exceptions/urls.py b/tests/regressiontests/middleware_exceptions/urls.py index 72c690fa41..ae78a65468 100644 --- a/tests/regressiontests/middleware_exceptions/urls.py +++ b/tests/regressiontests/middleware_exceptions/urls.py @@ -1,5 +1,5 @@ # coding: utf-8 -from django.conf.urls.defaults import * +from django.conf.urls import patterns import views diff --git a/tests/regressiontests/model_permalink/urls.py b/tests/regressiontests/model_permalink/urls.py index 6a84117a9b..409fc222c8 100644 --- a/tests/regressiontests/model_permalink/urls.py +++ b/tests/regressiontests/model_permalink/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^guitarists/(\w{1,50})/$', 'unimplemented_view_placeholder', name='guitarist_detail'), diff --git a/tests/regressiontests/special_headers/urls.py b/tests/regressiontests/special_headers/urls.py index 5d223fdb79..db19ab958d 100644 --- a/tests/regressiontests/special_headers/urls.py +++ b/tests/regressiontests/special_headers/urls.py @@ -1,5 +1,5 @@ # coding: utf-8 -from django.conf.urls.defaults import * +from django.conf.urls import patterns from django.views.generic.list_detail import object_detail from models import Article import views diff --git a/tests/regressiontests/staticfiles_tests/urls/default.py b/tests/regressiontests/staticfiles_tests/urls/default.py index 5788268175..e50a9e2907 100644 --- a/tests/regressiontests/staticfiles_tests/urls/default.py +++ b/tests/regressiontests/staticfiles_tests/urls/default.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^static/(?P.*)$', 'django.contrib.staticfiles.views.serve'), diff --git a/tests/regressiontests/syndication/urls.py b/tests/regressiontests/syndication/urls.py index 1f7ab73f71..ddbc7a130a 100644 --- a/tests/regressiontests/syndication/urls.py +++ b/tests/regressiontests/syndication/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns import feeds diff --git a/tests/regressiontests/templates/alternate_urls.py b/tests/regressiontests/templates/alternate_urls.py index e68f1c5875..ca74d64635 100644 --- a/tests/regressiontests/templates/alternate_urls.py +++ b/tests/regressiontests/templates/alternate_urls.py @@ -1,5 +1,5 @@ # coding: utf-8 -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from regressiontests.templates import views diff --git a/tests/regressiontests/templates/urls.py b/tests/regressiontests/templates/urls.py index 28d4133228..96e1ea2bfe 100644 --- a/tests/regressiontests/templates/urls.py +++ b/tests/regressiontests/templates/urls.py @@ -1,5 +1,5 @@ # coding: utf-8 -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from regressiontests.templates import views urlpatterns = patterns('', diff --git a/tests/regressiontests/test_client_regress/urls.py b/tests/regressiontests/test_client_regress/urls.py index 454f35b824..b973575509 100644 --- a/tests/regressiontests/test_client_regress/urls.py +++ b/tests/regressiontests/test_client_regress/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.views.generic import RedirectView import views diff --git a/tests/regressiontests/test_utils/urls.py b/tests/regressiontests/test_utils/urls.py index f3df170835..1bf0a0c756 100644 --- a/tests/regressiontests/test_utils/urls.py +++ b/tests/regressiontests/test_utils/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns import views diff --git a/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py b/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py index b09fff7e3e..8e6433e16e 100644 --- a/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url urlpatterns = patterns('', # View has erroneous import diff --git a/tests/regressiontests/urlpatterns_reverse/extra_urls.py b/tests/regressiontests/urlpatterns_reverse/extra_urls.py index c171f6d6f9..4dbfb90c22 100644 --- a/tests/regressiontests/urlpatterns_reverse/extra_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/extra_urls.py @@ -2,7 +2,7 @@ Some extra URL patterns that are included at the top level. """ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/included_named_urls.py b/tests/regressiontests/urlpatterns_reverse/included_named_urls.py index b3f7903b41..32d2b2976b 100644 --- a/tests/regressiontests/urlpatterns_reverse/included_named_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/included_named_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py b/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py index 96c42c3e4d..2a9779d64f 100644 --- a/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py +++ b/tests/regressiontests/urlpatterns_reverse/included_named_urls2.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py index 16887e2a9b..c878f97716 100644 --- a/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/included_namespace_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from namespace_urls import URLObject from views import view_class_instance diff --git a/tests/regressiontests/urlpatterns_reverse/included_urls.py b/tests/regressiontests/urlpatterns_reverse/included_urls.py index f8acf342f2..ae2c626336 100644 --- a/tests/regressiontests/urlpatterns_reverse/included_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/included_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/included_urls2.py b/tests/regressiontests/urlpatterns_reverse/included_urls2.py index f414ca638c..b6fb4c6a6a 100644 --- a/tests/regressiontests/urlpatterns_reverse/included_urls2.py +++ b/tests/regressiontests/urlpatterns_reverse/included_urls2.py @@ -5,7 +5,7 @@ each name to resolve and Django must distinguish the possibilities based on the argument list. """ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/named_urls.py b/tests/regressiontests/urlpatterns_reverse/named_urls.py index d8a61a106c..fa71f53c17 100644 --- a/tests/regressiontests/urlpatterns_reverse/named_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/named_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import empty_view urlpatterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py index 4e411eed9c..5a516f92cc 100644 --- a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import view_class_instance class URLObject(object): diff --git a/tests/regressiontests/urlpatterns_reverse/no_urls.py b/tests/regressiontests/urlpatterns_reverse/no_urls.py index c9b9efea78..5b1959c7dc 100644 --- a/tests/regressiontests/urlpatterns_reverse/no_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/no_urls.py @@ -1,2 +1,2 @@ -#from django.conf.urls.defaults import * +#from django.conf.urls import patterns, url, include diff --git a/tests/regressiontests/urlpatterns_reverse/reverse_lazy_urls.py b/tests/regressiontests/urlpatterns_reverse/reverse_lazy_urls.py index 0dff812707..5d336268d9 100644 --- a/tests/regressiontests/urlpatterns_reverse/reverse_lazy_urls.py +++ b/tests/regressiontests/urlpatterns_reverse/reverse_lazy_urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from views import empty_view, LazyRedirectView, login_required_view diff --git a/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py b/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py index e9819623a3..4d3fb74ca6 100644 --- a/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py +++ b/tests/regressiontests/urlpatterns_reverse/urlconf_inner.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.template import Template, Context from django.http import HttpResponse diff --git a/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py b/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py index 506e03666e..0762fc5db0 100644 --- a/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py +++ b/tests/regressiontests/urlpatterns_reverse/urlconf_outer.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include import urlconf_inner diff --git a/tests/regressiontests/urlpatterns_reverse/urls.py b/tests/regressiontests/urlpatterns_reverse/urls.py index ba59cf8f9a..6a324f042d 100644 --- a/tests/regressiontests/urlpatterns_reverse/urls.py +++ b/tests/regressiontests/urlpatterns_reverse/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import empty_view, absolute_kwargs_view other_patterns = patterns('', diff --git a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py index c2e0d32498..7a3e22078e 100644 --- a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py +++ b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers.py @@ -1,6 +1,6 @@ # Used by the ErrorHandlerResolutionTests test case. -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns urlpatterns = patterns('') diff --git a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py index 00f25a7236..c3d4855086 100644 --- a/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py +++ b/tests/regressiontests/urlpatterns_reverse/urls_error_handlers_callables.py @@ -1,6 +1,6 @@ # Used by the ErrorHandlerResolutionTests test case. -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns from views import empty_view 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 75a195ed14..0e58a157cf 100644 --- a/tests/regressiontests/urlpatterns_reverse/urls_without_full_import.py +++ b/tests/regressiontests/urlpatterns_reverse/urls_without_full_import.py @@ -1,7 +1,7 @@ # A URLs file that doesn't use the default -# from django.conf.urls.defaults import * +# from django.conf.urls import * # import pattern. -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from views import empty_view, bad_view urlpatterns = patterns('', diff --git a/tests/regressiontests/views/generic_urls.py b/tests/regressiontests/views/generic_urls.py index c608cc1c7f..cf2addc181 100644 --- a/tests/regressiontests/views/generic_urls.py +++ b/tests/regressiontests/views/generic_urls.py @@ -1,5 +1,5 @@ # -*- coding:utf-8 -*- -from django.conf.urls.defaults import patterns, url +from django.conf.urls import patterns, url from models import * diff --git a/tests/regressiontests/views/urls.py b/tests/regressiontests/views/urls.py index 6af725357b..2ce56b67f8 100644 --- a/tests/regressiontests/views/urls.py +++ b/tests/regressiontests/views/urls.py @@ -1,7 +1,7 @@ # coding: utf-8 from os import path -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include import views diff --git a/tests/urls.py b/tests/urls.py index b3f719d840..654111de60 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, include urlpatterns = patterns('',