#26155: Skip URL checks if settings.ROOTURL_CONF isn't defined
--------------------------------------+------------------------------------
Reporter: BuddyL | Owner: BuddyL
Type: Bug | Status: assigned
Component: Core (System checks) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by BuddyL):
If you return `None` for the settings of `ROOT_URLCONF` you get the
following excpetion:
{{{
Traceback (most recent call last):
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/urlresolvers.py", line 419, in url_patterns
iter(patterns)
TypeError: 'NoneType' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/management/__init__.py", line 353, in
execute_from_command_line
utility.execute()
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/management/base.py", line 398, in execute
self.check()
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/checks/urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/checks/urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/buddy/.venv/sk-client/lib/python3.4/site-
packages/django/core/urlresolvers.py", line 426, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: 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.
}}}
I modified the method to be. Not exactly sure how you mean to use an `if`
in this case.
{{{#!python
@lru_cache.lru_cache(maxsize=None)
def get_resolver(urlconf=None):
if urlconf is None:
from django.conf import settings
urlconf = getattr(settings, 'ROOT_URLCONF', None)
return RegexURLResolver(r'^/', urlconf)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26155#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.f49121348059bfa16247d917b88e6b98%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.