[Django] #35030: No async version of login_required

82 views
Skip to first unread message

Django

unread,
Dec 11, 2023, 4:35:00 PM12/11/23
to django-...@googlegroups.com
#35030: No async version of login_required
----------------------------------------+----------------------------------
Reporter: Mike Lissner | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: dev
Severity: Normal | Keywords: async, decorator
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+----------------------------------
We're slowly moving our code base over to async views and tests. Django
5.0 is a big leap forward for this, but we've found that there's still no
async version of the @login_required decorator.

We're working around it with some funky decorator usage:


{{{
@sync_to_async
@login_required
@async_to_sync
async def our_view(request):
}}}

Buuuut, it'd be great not to need to do all this and to either have an
async version of login_required (@alogin_required, perhaps?) or for it to
just work with async views.

I don't think there's an open issue for this, but amusingly, in
[https://code.djangoproject.com/ticket/31949#comment:27 a comment 11
months ago], Carlton Gibson touched on making login_required work with
async, but he thought it'd take another five years. Perhaps we can do
better. :)

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

Reply all
Reply to author
Forward
0 new messages