Opened 4 years ago
Closed 4 years ago
#31616 closed Cleanup/optimization (fixed)
Add hint to the E410 about AuthenticationMiddleware.
Reported by: | Keryn Knight | Owned by: | Hasan Ramezani |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Given an empty MIDDLEWARE
in your project, you try and run the admin.
The system checks framework kicks in, giving you:
(admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application. (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application. (admin.E410) 'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.
You add each of those middlewares to the stack, and run the application:
File "/path/to/django/contrib/auth/middleware.py", line 23, in process_request ) % ("_CLASSES" if settings.MIDDLEWARE is None else "") AssertionError: The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE setting to insert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'
Ignoring the fact that it should be a system check, and it's an unfortunate side-effect of spanning 2 separate contrib apps that it isn't, if the order of the errors output was updated, we'd not see this exception in this specific scenario.
Change History (3)
comment:1 by , 4 years ago
Easy pickings: | set |
---|---|
Summary: | Change order of admin.checks.check_dependencies so that admin.E410 comes before admin.E408 → Add hint to the E410 about AuthenticationMiddleware. |
Triage Stage: | Unreviewed → Accepted |
Version: | 3.0 → master |
Note:
See TracTickets
for help on using tickets.
I agree that we can do sth better here, but I'm not sure if maintaining the order of checks is feasible in a long-term. I would add a hint to the
E410
, e.g.