[Django] #31616: Change order of admin.checks.check_dependencies so that admin.E410 comes before admin.E408

10 views
Skip to first unread message

Django

unread,
May 22, 2020, 3:55:14 AM5/22/20
to django-...@googlegroups.com
#31616: Change order of admin.checks.check_dependencies so that admin.E410 comes
before admin.E408
------------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/31616>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 25, 2020, 3:44:27 AM5/25/20
to django-...@googlegroups.com
#31616: Add hint to the E410 about AuthenticationMiddleware.
--------------------------------------+------------------------------------

Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* version: 3.0 => master
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

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.

> Insert 'django.contrib.sessions.middleware.SessionMiddleware' before
'django.contrib.auth.middleware.AuthenticationMiddleware'.

--
Ticket URL: <https://code.djangoproject.com/ticket/31616#comment:1>

Django

unread,
May 25, 2020, 11:01:21 AM5/25/20
to django-...@googlegroups.com
#31616: Add hint to the E410 about AuthenticationMiddleware.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned

Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/12973 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31616#comment:2>

Django

unread,
May 25, 2020, 4:16:40 PM5/25/20
to django-...@googlegroups.com
#31616: Add hint to the E410 about AuthenticationMiddleware.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"18759b2209ff556aed7f20d83cbf23e3d234e41c" 18759b22]:
{{{
#!CommitTicketReference repository=""
revision="18759b2209ff556aed7f20d83cbf23e3d234e41c"
Fixed #31616 -- Added hint about middleware ordering for SessionMiddleware
admin check.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31616#comment:3>

Reply all
Reply to author
Forward
0 new messages