Opened 4 years ago
Closed 4 years ago
#32228 closed New feature (duplicate)
csrf_exempt decorator async support
Reported by: | André Zanghelini | Owned by: | nobody |
---|---|---|---|
Component: | CSRF | Version: | 3.1 |
Severity: | Normal | Keywords: | async |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
After losing an entire day with a cryptic message telling me my view:
didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view.
Even though the function was a literal single line return HttpResponse('a')
. On the next day I found out the problem was because I was using the csrf_exempt
decorator.
This patch 'fixes' that, allowing this decorator to be used by async functions as well.
Couldn't find how to make an automated test for that so it's not included, someone else has to create it or guide me on where and how to do it.
Flake8 didn't complain and there's no need for extra documentation as it just improves async support in more existing features.
Code at Github
https://github.com/django/django/pull/13720
Change History (2)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|---|
Needs tests: | set |
comment:2 by , 4 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #31949.