summaryrefslogtreecommitdiff
path: root/django/conf/urls
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-10 09:57:49 -0500
committerTim Graham <timograham@gmail.com>2017-01-17 20:52:00 -0500
commitad393beeb71e8774e4bf9ad842b97022e50f1231 (patch)
tree7ae0a539e53c582865a57273d902b3f29192d699 /django/conf/urls
parentc6de8cca208fb471723619970c09ecb3bd335362 (diff)
Refs #21927 -- Removed include()'s app_name argument per deprecation timeline.
Also removed support for passing a 3-tuple to include() and support for setting an instance namespace without an application namespace. Thanks Marten Kenbeek for completing the patch.
Diffstat (limited to 'django/conf/urls')
-rw-r--r--django/conf/urls/__init__.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/django/conf/urls/__init__.py b/django/conf/urls/__init__.py
index 03879bccd4..45af3a10d2 100644
--- a/django/conf/urls/__init__.py
+++ b/django/conf/urls/__init__.py
@@ -1,4 +1,3 @@
-import warnings
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
@@ -6,7 +5,6 @@ from django.urls import (
LocaleRegexURLResolver, RegexURLPattern, RegexURLResolver,
)
from django.utils import six
-from django.utils.deprecation import RemovedInDjango20Warning
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'url']
@@ -16,16 +14,8 @@ handler404 = 'django.views.defaults.page_not_found'
handler500 = 'django.views.defaults.server_error'
-def include(arg, namespace=None, app_name=None):
- if app_name and not namespace:
- raise ValueError('Must specify a namespace if specifying app_name.')
- if app_name:
- warnings.warn(
- 'The app_name argument to django.conf.urls.include() is deprecated. '
- 'Set the app_name in the included URLconf instead.',
- RemovedInDjango20Warning, stacklevel=2
- )
-
+def include(arg, namespace=None):
+ app_name = None
if isinstance(arg, tuple):
# callable returning a namespace hint
try:
@@ -35,13 +25,11 @@ def include(arg, namespace=None, app_name=None):
raise ImproperlyConfigured(
'Cannot override the namespace for a dynamic module that provides a namespace'
)
- warnings.warn(
- 'Passing a 3-tuple to django.conf.urls.include() is deprecated. '
+ raise ImproperlyConfigured(
+ 'Passing a 3-tuple to django.conf.urls.include() is not supported. '
'Pass a 2-tuple containing the list of patterns and app_name, '
'and provide the namespace argument to include() instead.',
- RemovedInDjango20Warning, stacklevel=2
)
- urlconf_module, app_name, namespace = arg
else:
# No namespace hint - use manually provided namespace
urlconf_module = arg
@@ -51,12 +39,11 @@ def include(arg, namespace=None, app_name=None):
patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
app_name = getattr(urlconf_module, 'app_name', app_name)
if namespace and not app_name:
- warnings.warn(
+ raise ImproperlyConfigured(
'Specifying a namespace in django.conf.urls.include() without '
- 'providing an app_name is deprecated. Set the app_name attribute '
+ 'providing an app_name is not supported. Set the app_name attribute '
'in the included module, or pass a 2-tuple containing the list of '
'patterns and app_name instead.',
- RemovedInDjango20Warning, stacklevel=2
)
namespace = namespace or app_name