diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-22 15:36:49 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-22 15:36:49 +0100 |
| commit | 173aa5199737c60ab883a0469684e83c01604ce8 (patch) | |
| tree | b78d1f2848a18867fb2d642056c6354f207564d3 /django | |
| parent | d399731bf29bf842c756a77ff8a58706bac3d65f (diff) | |
Fixed #21435 -- Improved error message when urlconf is empty.
The new error message now hints that the most likely issue
is a circular import.
Thanks to trac user elena for the report and to
bpeschier for the original patch.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/urlresolvers.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 1dca15b4aa..08aaa40493 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -346,11 +346,17 @@ class RegexURLResolver(LocaleRegexProvider): @property def url_patterns(self): + # urlconf_module might be a valid set of patterns, so we default to it patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) try: iter(patterns) except TypeError: - raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name) + 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." + ) + raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) return patterns def _resolve_special(self, view_type): |
