mirror of https://github.com/django/django.git
Refs #26601 -- Removed obsolete workarounds for MIDDLEWARE_CLASSES setting.
This commit is contained in:
parent
d4e767911f
commit
0315c18fe1
|
@ -18,10 +18,8 @@ class XViewMiddleware(MiddlewareMixin):
|
|||
"""
|
||||
assert hasattr(request, 'user'), (
|
||||
"The XView middleware requires authentication middleware to be "
|
||||
"installed. Edit your MIDDLEWARE%s setting to insert "
|
||||
"'django.contrib.auth.middleware.AuthenticationMiddleware'." % (
|
||||
"_CLASSES" if settings.MIDDLEWARE is None else ""
|
||||
)
|
||||
"installed. Edit your MIDDLEWARE setting to insert "
|
||||
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
|
||||
)
|
||||
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or
|
||||
(request.user.is_active and request.user.is_staff)):
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from django.conf import settings
|
||||
from django.contrib import auth
|
||||
from django.contrib.auth import load_backend
|
||||
from django.contrib.auth.backends import RemoteUserBackend
|
||||
|
@ -17,10 +16,10 @@ class AuthenticationMiddleware(MiddlewareMixin):
|
|||
def process_request(self, request):
|
||||
assert hasattr(request, 'session'), (
|
||||
"The Django authentication middleware requires session middleware "
|
||||
"to be installed. Edit your MIDDLEWARE%s setting to insert "
|
||||
"to be installed. Edit your MIDDLEWARE setting to insert "
|
||||
"'django.contrib.sessions.middleware.SessionMiddleware' before "
|
||||
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
|
||||
) % ("_CLASSES" if settings.MIDDLEWARE is None else "")
|
||||
)
|
||||
request.user = SimpleLazyObject(lambda: get_user(request))
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.messages.storage.base import BaseStorage
|
||||
from django.contrib.messages.storage.cookie import (
|
||||
MessageDecoder, MessageEncoder,
|
||||
|
@ -17,7 +16,7 @@ class SessionStorage(BaseStorage):
|
|||
assert hasattr(request, 'session'), "The session-based temporary "\
|
||||
"message storage requires session middleware to be installed, "\
|
||||
"and come before the message middleware in the "\
|
||||
"MIDDLEWARE%s list." % ("_CLASSES" if settings.MIDDLEWARE is None else "")
|
||||
"MIDDLEWARE list."
|
||||
super().__init__(request, *args, **kwargs)
|
||||
|
||||
def _get(self, *args, **kwargs):
|
||||
|
|
|
@ -163,7 +163,7 @@ class CsrfViewMiddleware(MiddlewareMixin):
|
|||
raise ImproperlyConfigured(
|
||||
'CSRF_USE_SESSIONS is enabled, but request.session is not '
|
||||
'set. SessionMiddleware must appear before CsrfViewMiddleware '
|
||||
'in MIDDLEWARE%s.' % ('_CLASSES' if settings.MIDDLEWARE is None else '')
|
||||
'in MIDDLEWARE.'
|
||||
)
|
||||
else:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue