Using async class-based views

Hi,

The docs say the following about using async with CBVs:

Any view can be declared async by making the callable part of it return a coroutine - commonly, this is done using async def. For a function-based view, this means declaring the whole view using async def. For a class-based view, this means declaring the HTTP method handlers, such as get() and post() as async def (not its init(), or as_view()).

But what does that mean in relation to urls.py where I’d normally call e.g.:

path("jobs/<int:pk>", JobView.as_view(), name="jobgroup_detail"),

This doesn’t work with uvicorn:

class JobView(
    LoginRequiredMixin,
    View,
):
    async def get(self, request, *args, **kwargs):
        action = request.GET.get("action", "")
        ....

It previously worked before I changed to CBV, so the async stuff is all set up properly.

Ah dw it does work.

From other docs:

If a View subclass defines asynchronous (async def) method handlers, as_view() will mark the returned callable as a coroutine function. An ImproperlyConfigured exception will be raised if both asynchronous (async def) and synchronous (def) handlers are defined on a single view-class.