mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #14200 -- Added a fallback if HttpRequest.urlconf is None.
Made BaseHandler fall back to settings.ROOT_URLCONF if HttpRequest.urlconf is set to None, rather than raising ImproperlyConfigured.
This commit is contained in:
committed by
Tim Graham
parent
74402a5b0d
commit
738c0de300
@@ -184,6 +184,14 @@ All attributes should be considered read-only, unless stated otherwise below.
|
||||
URLconf for the current request, overriding the :setting:`ROOT_URLCONF`
|
||||
setting. See :ref:`how-django-processes-a-request` for details.
|
||||
|
||||
``urlconf`` can be set to ``None`` to revert any changes made by previous
|
||||
middleware and return to using the :setting:`ROOT_URLCONF`.
|
||||
|
||||
.. versionchanged:: 1.9
|
||||
|
||||
Setting ``urlconf=None`` raised
|
||||
:exc:`~django.core.exceptions.ImproperlyConfigured` in older versions.
|
||||
|
||||
.. attribute:: HttpRequest.resolver_match
|
||||
|
||||
An instance of :class:`~django.core.urlresolvers.ResolverMatch` representing
|
||||
|
||||
@@ -435,6 +435,10 @@ Requests and Responses
|
||||
:class:`~django.template.response.TemplateResponse`, commonly used with
|
||||
class-based views.
|
||||
|
||||
* Request middleware can now set :attr:`HttpRequest.urlconf
|
||||
<django.http.HttpRequest.urlconf>` to ``None`` to revert any changes made
|
||||
by previous middleware and return to using the :setting:`ROOT_URLCONF`.
|
||||
|
||||
Tests
|
||||
^^^^^
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ algorithm the system follows to determine which Python code to execute:
|
||||
|
||||
1. Django determines the root URLconf module to use. Ordinarily,
|
||||
this is the value of the :setting:`ROOT_URLCONF` setting, but if the incoming
|
||||
``HttpRequest`` object has an attribute called ``urlconf`` (set by
|
||||
middleware :ref:`request processing <request-middleware>`), its value
|
||||
will be used in place of the :setting:`ROOT_URLCONF` setting.
|
||||
``HttpRequest`` object has a :attr:`~django.http.HttpRequest.urlconf`
|
||||
attribute (set by middleware :ref:`request processing <request-middleware>`),
|
||||
its value will be used in place of the :setting:`ROOT_URLCONF` setting.
|
||||
|
||||
2. Django loads that Python module and looks for the variable
|
||||
``urlpatterns``. This should be a Python list of :func:`django.conf.urls.url`
|
||||
|
||||
Reference in New Issue
Block a user