generic views and async

hi
so i’m not sure if this has been discussed before or not
i did search but answers seem to be old

so i want to use asgi for my new porject and my habbit is to use generic views and class based views

but i’m kinda stuck in the sense that i don’t know how much of the generic views should i overwrite in order for async to work

or perhaps django does this for me somehow?

for example if i want to use a CreateView, should i overwrite the methods such as get, post, get_context_data, and… to be async and use await in then and other async stuff
or what?

1 Like

At a minimum, you’re going to need to adapt all ORM-related operations and the rendering process. For example in a detail view, this means overriding (at least) the get_object and render_to_response methods.

You don’t need to override the various methods that just bounce you from method to method.

If you’re really serious about this, I’d suggest you create your own async-friendly CBVs and inherit from them in your code.

Otherwise, you’re probably just as well off marking the entire view as sync and letting it go at that.

1 Like