You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make Django's ORM fully support async operations, so we can await database queries directly without needing workarounds like sync_to_async( ).
Problem
Right now, even though Django supports ASGI and async views, the ORM is still synchronous. This means when we hit the database inside an async view, it blocks a thread, and we lose the performance benefits of running an async server. We have to use extra things like sync_to_async(), which makes the code messier and not truly async. If the ORM could be used with await, Django apps could handle a lot more traffic, work better with real-time apps, and feel more modern overall.
Request or proposal
request
Additional Details
Adding full async ORM support would make Django even better for modern applications like real-time dashboards, high-frequency APIs, and IoT data platforms.
For example, in my own projects (like a Smart Community Data Platform handling IoT data), using a fully async ORM would help scale better and reduce latency by avoiding blocking calls in async views. Today, because Django's ORM is still synchronous, I sometimes choose other frameworks like FastAPI with Tortoise ORM when I need full async performance end-to-end.
However, I still prefer Django for many parts of my systems, especially for building admin panels, billing services, and reliable backend management features where Django’s strengths shine. I believe that with native async ORM support, Django could stay the first choice for both traditional and high-concurrency projects.
Thanks for considering this! I'm very excited about Django’s future with more async capabilities.
Implementation Suggestions
These suggestions are inspired by patterns I've seen working well in other fully async Python frameworks like Tortoise ORM and SQLModel:
Add async methods like aget(), acreate(), asave() to Django’s ORM, so developers can await database operations directly.
Use async database drivers like asyncpg for Postgres connections under the hood.
Allow QuerySets to be evaluated inside async contexts without blocking.
Improve transaction management (like atomic blocks) to be async-friendly and safe in event loops.
Maybe introduce this feature behind a settings flag first, like settings.USE_ASYNC_ORM = True, so people can opt in during early phases.
This way, async ORM support could be rolled out gradually in Django without breaking existing synchronous projects.
The text was updated successfully, but these errors were encountered:
Thank you dilroop-us for sharing your idea! We have a lot of them so please be patient. You can see the current queue here. If you'd like to learn about other ways to get this idea more attention, please see this page.
Community instructions
For commenters, please use the emoji reactions on the issue to express support, and/or concern easily. Please use the comments to ask questions or contribute knowledge about the idea. It is unhelpful to post comments of "I'd love this" or "What's the state of this?"
Reaction Guide
👍 This is something I would use
👎 This is something that would cause problems for me or Django
I believe this is already in progress as we have a DEP for async support accepted. For each of the various pieces you've identified, we're in the "Can we do it?" and "Wait for resources" stage.
Glad to know this is already part of DEP 0009.
I'm excited to follow the progress and would be happy to help test or contribute small things in the future.
Code of Conduct
Feature Description
Make Django's ORM fully support async operations, so we can
await
database queries directly without needing workarounds likesync_to_async( )
.Problem
Right now, even though Django supports ASGI and async views, the ORM is still synchronous. This means when we hit the database inside an async view, it blocks a thread, and we lose the performance benefits of running an async server. We have to use extra things like
sync_to_async()
, which makes the code messier and not truly async. If the ORM could be used withawait
, Django apps could handle a lot more traffic, work better with real-time apps, and feel more modern overall.Request or proposal
request
Additional Details
Adding full async ORM support would make Django even better for modern applications like real-time dashboards, high-frequency APIs, and IoT data platforms.
For example, in my own projects (like a Smart Community Data Platform handling IoT data), using a fully async ORM would help scale better and reduce latency by avoiding blocking calls in async views. Today, because Django's ORM is still synchronous, I sometimes choose other frameworks like FastAPI with Tortoise ORM when I need full async performance end-to-end.
However, I still prefer Django for many parts of my systems, especially for building admin panels, billing services, and reliable backend management features where Django’s strengths shine. I believe that with native async ORM support, Django could stay the first choice for both traditional and high-concurrency projects.
Thanks for considering this! I'm very excited about Django’s future with more async capabilities.
Implementation Suggestions
These suggestions are inspired by patterns I've seen working well in other fully async Python frameworks like Tortoise ORM and SQLModel:
This way, async ORM support could be rolled out gradually in Django without breaking existing synchronous projects.
The text was updated successfully, but these errors were encountered: