﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32077	HTTP view decorators (require_http_methods) not working with async views	Hendrik Frentrup	nobody	"HTTP view decorators don't work with async views, though I don't see why they shouldn't given they don't use the ORM (unlike the login_required decorator for example).
The following throws a `ValueError`
{{{
@require_http_methods(['GET'])
async def blog_info(request, blog_id):
    blog = await sync_to_async(Blog.objects.get)(id=blog_id)
    return HttpResponse(f""got spot #id: {blog_id} - name: {blog.name}"")
}}}
Here is the error:
{{{
ValueError: The view myapp.views.blog_info didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view.
}}}
From what I can see this is due to the decorator calling the async function after checking the request headers and returning but returning a non-async function (`return inner`) in `django.views.decorators.http`
How to handle middleware with async seems to be a point of contention still, but these decorators are hardly middleware, so I think it would be worth fixing. From some initial testing, it doesn't seem to be a difficult fix either.
"	New feature	closed	HTTP handling	3.1	Normal	duplicate	async views decorators		Unreviewed	0	0	0	0	0	0
