[Django] #37178: Move MiddlewareMixin out of utils.deprecation

5 views
Skip to first unread message

Django

unread,
Jun 18, 2026, 10:26:32 AM (yesterday) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type:
| Cleanup/optimization
Status: new | Component: HTTP
| handling
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Following some mastodon
[https://mastodon.social/@farhanaliraza/115418201200232304 chatter] kicked
off by Farhan last fall, Carlton
[https://discord.com/channels/856567261900832808/1430567236271079474/1430587741539668020
replied] with an answer about why `MiddlewareMixin` lives under
`utils.deprecation`:

> I think it was meant to go away as we all moved to function based
middleware. Then that never happened. Then MiddlewareMixin grew the async
adaption two-step, and it’s useful for that. Even if we just use it
internally, it should probably be moved. (Clean code and all that Jazz)

We have some +1s on that Mastodon thread, ending with "if a fellow picks
it up", so here I am, proposing to move it :-)

We could choose to leave a single alias in `utils.deprecation` to avoid
breaking changes for people explicitly importing `MiddlewareMixin`. It's a
lot simpler than adding a release note or a deprecation path. (I might be
in the minority with this view, though.)
--
Ticket URL: <https://code.djangoproject.com/ticket/37178>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 18, 2026, 10:44:20 AM (yesterday) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: dev
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 Carlton Gibson):

* stage: Unreviewed => Accepted

Comment:

OK, yep. Nice hustle.

Deprecation could use a [https://peps.python.org/pep-0562/ module level
__getattr__] to raise the DeprecationWarning. 🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:1>

Django

unread,
Jun 18, 2026, 11:52:43 AM (yesterday) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
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 CharulL00):

* owner: (none) => CharulL00
* status: new => assigned

Comment:

I’m claiming this ticket and will work on a patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:2>

Django

unread,
Jun 18, 2026, 3:10:14 PM (yesterday) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
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 CharulL00):

* has_patch: 0 => 1

Comment:

PR submitted: https://github.com/django/django/pull/21517
--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:3>

Django

unread,
Jun 18, 2026, 4:00:48 PM (yesterday) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
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 CharulL00):

* has_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:4>

Django

unread,
Jun 18, 2026, 5:03:45 PM (24 hours ago) Jun 18
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
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 CharulL00):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:5>

Django

unread,
2:43 PM (2 hours ago) 2:43 PM
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
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
-------------------------------------+-------------------------------------
Comment (by Mike Edmunds):

Replying to [comment:1 Carlton Gibson]:
> [...] Deprecation could use a [https://peps.python.org/pep-0562/ module
level __getattr__] to raise the DeprecationWarning. 🤔

It probably should. In the past, retaining multiple supported import paths
to things that move has been considered a maintenance burden, and
deprecating the old path was preferred. (Trying to remember the specific
example where this came up.)
--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:6>

Django

unread,
2:46 PM (2 hours ago) 2:46 PM
to django-...@googlegroups.com
#37178: Move MiddlewareMixin out of utils.deprecation
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: CharulL00
Type: | Status: assigned
Cleanup/optimization |
Component: HTTP handling | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37178#comment:7>
Reply all
Reply to author
Forward
0 new messages