summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-08 13:44:07 -0500
committerTim Graham <timograham@gmail.com>2015-02-12 08:07:58 -0500
commit27eeb64a96ec6d3a05714ab6319b500a935706fb (patch)
tree19ac095da21252246c8a0007fe3150f7dd1934ed
parent34ccb3cc038ac30b13a7243a3dbd9366c1119746 (diff)
Fixed #17716 -- Prevented include('...', app_name='...') without a namespace.
-rw-r--r--django/conf/urls/__init__.py3
-rw-r--r--tests/urlpatterns_reverse/tests.py10
2 files changed, 12 insertions, 1 deletions
diff --git a/django/conf/urls/__init__.py b/django/conf/urls/__init__.py
index 094b4cb3e8..6ed54930c4 100644
--- a/django/conf/urls/__init__.py
+++ b/django/conf/urls/__init__.py
@@ -17,6 +17,9 @@ 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 isinstance(arg, tuple):
# callable returning a namespace hint
if namespace:
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index 3835e09c08..ddb8fa556a 100644
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -10,6 +10,7 @@ import unittest
from admin_scripts.tests import AdminScriptTestCase
from django.conf import settings
+from django.conf.urls import include
from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
from django.core.urlresolvers import (
@@ -399,7 +400,7 @@ class ReverseShortcutTests(TestCase):
@ignore_warnings(category=RemovedInDjango20Warning)
def test_reverse_by_path_nested(self):
# Views that are added to urlpatterns using include() should be
- # reversible by doted path.
+ # reversible by dotted path.
self.assertEqual(reverse('urlpatterns_reverse.views.nested_view'), '/includes/nested_path/')
def test_redirect_view_object(self):
@@ -749,3 +750,10 @@ class ViewLoadingTests(TestCase):
# swallow it.
self.assertRaises(AttributeError, get_callable,
'urlpatterns_reverse.views_broken.i_am_broken')
+
+
+class IncludeTests(SimpleTestCase):
+ def test_include_app_name_but_no_namespace(self):
+ msg = "Must specify a namespace if specifying app_name."
+ with self.assertRaisesMessage(ValueError, msg):
+ include('urls', app_name='bar')