Skip to content

Add Full Async Support for Django ORM #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
dilroop-us opened this issue Apr 27, 2025 · 5 comments
Open
1 task done

Add Full Async Support for Django ORM #7

dilroop-us opened this issue Apr 27, 2025 · 5 comments
Labels
Async Django Core This idea is suitable for inclusion in Django itself Models/ORM

Comments

@dilroop-us
Copy link

Code of Conduct

  • I agree to follow Django's Code of Conduct

Feature Description

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.

Copy link

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’m indifferent to this
  • 🎉 This is an easy win

@tim-schilling
Copy link
Member

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.

@dilroop-us
Copy link
Author

Thanks a lot for the clarification!

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.

Appreciate all the work being done!

@nessita

This comment has been minimized.

@LilyAcorn LilyAcorn moved this from Idea to In progress in New Features Apr 28, 2025
@LilyAcorn LilyAcorn added the Django Core This idea is suitable for inclusion in Django itself label Apr 29, 2025
@tim-schilling

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Async Django Core This idea is suitable for inclusion in Django itself Models/ORM
Projects
Status: In progress
Development

No branches or pull requests

4 participants