summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Fernandes <igorkuivjogi@hotmail.com>2021-05-26 16:06:47 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-06-22 08:09:53 +0200
commite85d9c02ad1ef8988c149bad905fbc5b98a38594 (patch)
tree7b8ea1ce77cd94976343a05c0f33ee413087c407
parentee408309d2007ecec4f43756360bd855d424cbf6 (diff)
Fixed #32870 -- Improved error message when URLconf is empty.
-rw-r--r--django/urls/resolvers.py7
-rw-r--r--tests/urlpatterns_reverse/tests.py10
2 files changed, 10 insertions, 7 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
index 674fd0c58e..3a53bce1de 100644
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -626,9 +626,10 @@ class URLResolver:
iter(patterns)
except TypeError as e:
msg = (
- "The included URLconf '{name}' does not appear to have any "
- "patterns in it. If you see valid patterns in the file then "
- "the issue is probably caused by a circular import."
+ "The included URLconf '{name}' does not appear to have "
+ "any patterns in it. If you see the 'urlpatterns' variable "
+ "with valid patterns in the file then the issue is probably "
+ "caused by a circular import."
)
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
return patterns
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index 7190023d3a..f2102c5304 100644
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -271,8 +271,9 @@ class NoURLPatternsTests(SimpleTestCase):
with self.assertRaisesMessage(
ImproperlyConfigured,
"The included URLconf 'urlpatterns_reverse.no_urls' does not "
- "appear to have any patterns in it. If you see valid patterns in "
- "the file then the issue is probably caused by a circular import."
+ "appear to have any patterns in it. If you see the 'urlpatterns' "
+ "variable with valid patterns in the file then the issue is "
+ "probably caused by a circular import."
):
getattr(resolver, 'url_patterns')
@@ -1095,8 +1096,9 @@ class NoRootUrlConfTests(SimpleTestCase):
def test_no_handler_exception(self):
msg = (
"The included URLconf 'None' does not appear to have any patterns "
- "in it. If you see valid patterns in the file then the issue is "
- "probably caused by a circular import."
+ "in it. If you see the 'urlpatterns' variable with valid patterns "
+ "in the file then the issue is probably caused by a circular "
+ "import."
)
with self.assertRaisesMessage(ImproperlyConfigured, msg):
self.client.get('/test/me/')