[Django] #37124: AccessMixin: object HttpResponseRedirect can't be used in 'await' expression

7 views
Skip to first unread message

Django

unread,
May 28, 2026, 4:35:07 AM (3 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+-----------------------------------------
Reporter: Johannes Maron | Type: Bug
Status: new | Component: Uncategorized
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
--------------------------------+-----------------------------------------
The redirect response in AccessMixin.handle_no_permission isn't async
compatible.

If you have access, everything works fine, since all HTTP method handlers
are async and return coroutines; only if you lack permissions or are
unauthenticated is the redirect response synchronous.

With access to `view_is_async` it should be a fairly easy fix to have
`handle_no_permission` return a coroutine.

Thanks to @amirreza-sf80 for reporting:
https://github.com/django/new-features/issues/162#issuecomment-4562082172

I could find the bug on Stack Overflow as well, but no ticket on Trac:
https://stackoverflow.com/questions/66512353/using-loginrequiredmixin-
with-async-views
--
Ticket URL: <https://code.djangoproject.com/ticket/37124>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 28, 2026, 4:45:44 AM (3 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: Bug | Status: new
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Comment (by amirreza):

should mention `LoginRequiredMixin` also uses
`request.user.is_authenticated` inside `dispatch`, but it should use
`auser` instead,
which requires awaiting.
--
Ticket URL: <https://code.djangoproject.com/ticket/37124#comment:1>

Django

unread,
May 28, 2026, 5:20:18 AM (3 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: ZKY
Type: Bug | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by ZKY):

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

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

Django

unread,
May 28, 2026, 4:15:06 PM (2 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: Bug | Status: new
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Johannes Maron):

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

Comment:

As much as I share your enthusiasm, @ZKY, please be so kind and follow the
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/ ticket workflow] and either wait for triage or do it yourself.
Tickets must be accepted before they are assigned.
--
Ticket URL: <https://code.djangoproject.com/ticket/37124#comment:3>

Django

unread,
May 28, 2026, 11:09:49 PM (2 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: Bug | Status: new
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Comment (by ZKY):

Oh, apologies! I didn't realize I could triage and accept the status
myself. I have successfully reproduced this issue locally with a minimal
script now.

I'll update the Triage Stage to 'Accepted', re-assign it to myself, and
open a PR with the sync_to_async and auser() fix this weekend. Thanks for
guiding me through the workflow!
--
Ticket URL: <https://code.djangoproject.com/ticket/37124#comment:4>

Django

unread,
May 28, 2026, 11:10:47 PM (2 days ago) May 28
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+------------------------------------
Reporter: Johannes Maron | Owner: ZKY
Type: Bug | Status: assigned
Component: Uncategorized | 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 ZKY):

* owner: (none) => ZKY
* stage: Unreviewed => Accepted
* status: new => assigned

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

Django

unread,
6:35 AM (14 hours ago) 6:35 AM
to django-...@googlegroups.com
#37124: AccessMixin: object HttpResponseRedirect can't be used in 'await'
expression
--------------------------------+------------------------------------
Reporter: Johannes Maron | Owner: zky
Type: Bug | Status: assigned
Component: Uncategorized | 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 zky):

* has_patch: 0 => 1

Comment:

https://github.com/django/django/pull/21378
--
Ticket URL: <https://code.djangoproject.com/ticket/37124#comment:6>
Reply all
Reply to author
Forward
0 new messages