Skip to content

Add Full Async Support for Django ORM #7

Open
@dilroop-us

Description

@dilroop-us

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncDjango CoreThis idea is suitable for inclusion in Django itselfModels/ORM

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions