Django 3.2 Async Support: What You Need to Know

Logan Kilpatrick
2 min readJul 12, 2021

--

Since the release of Django 3.0 in December of 2019, the wildly popular web framework has begun the journey to support Async through ASGI. For those new to Async, here is a little more context of ASGI:

ASGI (Asynchronous Server Gateway Interface) is a spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks, and applications.

But what does this all really mean? As a Django user and web developer, why does this matter to me?

Depending on the specifics of your Django project, async functions could allow you to make database updates or requests while still going about other processes. For many simple Django applications, this will not matter since the code is likely written in a way that does not do complex processes, but for use-cases like messaging services or perhaps a complex dashboard, these async functions can really solve a performance bottleneck.

Let’s take a quick look at this idea in practice:

Example Django project showing the new async function

In the above example, we can see the fetch_listings function is defined using the async keyword which allows that function to be called asyncronously. The function itself is simply retrieving entries from the database so this is one of the main potential use-cases of this async functionality.

Under the hood, any async function is returning a co-routine. This should not make much of a difference since Django takes care of managing this in many cases, but it’s good to be aware of the proverbial magic that is taking place.

Hopefully this gets you excited about the potential of async functions in Django! There are already a ton of amazing resources out there if you want to dive in so I suggest checking out the links below to get started. Happy coding!

Want to read more about Async in Django? Check out these articles:

--

--

Logan Kilpatrick
Logan Kilpatrick

Written by Logan Kilpatrick

Lead product for Google AI Studio, working on the Gemini API, and AGI. Ex-OpenAI.