MongoDB Django Backend Now Available in Public Preview

Peter Richards

We are pleased to announce that the MongoDB Django Backend Public Preview is now available. This Python package makes it easier than ever to combine the sensible defaults and fast development speed Django provides with the convenience and ease of MongoDB.

Building for the Python community

For years, Django has been consistently rated one of the most popular web frameworks in the Python ecosystem. It’s a powerful tool for building web applications quickly and securely, and implements best practices by default while abstracting away complexity. Over the last few years, Django developers have increasingly used MongoDB, presenting an opportunity for an official MongoDB-built Python package to make integrating both technologies as painless as possible.

We recognize that success in this endeavor requires more than just technical expertise in database systems—it demands a deep understanding of Django's ecosystem, conventions, and the needs of its developer community. So we’re committed to ensuring that the MongoDB Django Backend not only meets the technical requirements of developers, but also feels painless and intuitive, and is a natural complement to the base Django framework.

What’s in the MongoDB Django Backend

In this public preview release, the MongoDB Django Backend offers developers the following capabilities:

  • The ability to use Django models with confidence. Developers can use Django models to represent MongoDB documents, with support for Django forms, validations, and authentication.

  • Django admin support. The package allows users to fire up the Django admin page as they normally would, with full support for migrations and database schema history.

  • Native connecting from settings.py. Just as with any other database provider, developers can customize the database engine in settings.py to get MongoDB up and running.

  • MongoDB-specific querying optimizations. Field lookups have been replaced with aggregation calls (aggregation stages and aggregate operators), JOIN operations are represented through $lookup, and it’s possible to build indexes right from Python.

  • Limited advanced functionality. While still in development, the package already has support for time series, projections, and XOR operations.

  • Aggregation pipeline support. Raw querying allows aggregation pipeline operators. Since aggregation is a superset of what traditional MongoDB Query API methods provide, it gives developers more functionality.

And this is just the start—more functionality (including BSON data type support and embedded document support in arrays) is on its way. Stay tuned for the General Availability release later in 2025!

Benefits of using the MongoDB Django Backend

While during the public preview MongoDB requires more work to set up in the initial stages of development than Django’s defaults, the payoff that comes from the flexibility of the document model and the full feature set of Atlas makes that tradeoff worth it over the whole lifecycle of a project. With the MongoDB Django Backend, developers can architect applications in a distinct and novel way, denormalizing their data and creating Django models so that data that is accessed together is stored together. These models are both easier to maintain and their retrieval is more performant for a number of use cases—which when paired with the robust, native Django experience MongoDB is creating is a compelling offering, improving the developer experience and accelerating software development.

At its core, the MongoDB document model aligns well with Django's mission to “encourage rapid development and clean, pragmatic design.” The MongoDB document model naturally mirrors how developers think about and structure their data in code, allowing for a seamless context switch between a Django model and a MongoDB document. For many modern applications— especially those dealing with hierarchical, semi-structured, or rapidly evolving data structures— the document model provides a more natural and flexible solution than traditional relational databases.

Dovetailing with this advantage is the fact it’s simpler than ever to develop locally with MongoDB, thanks to how painless it is to create a local Atlas deployment with Docker. With sensible preconfigured defaults, it’s possible to create a single-node replica set simply by pulling the Docker image and running it, using only an Atlas connection string, and no extra steps needed. The best part? It’s even possible to convert an existing Atlas implementation running in Docker Compose to a local image. Developing with Django and MongoDB just works with the Atlas CLI and Docker.

How to get started with the MongoDB Django Backend

To get started, it’s as easy as running pip install django-mongo-backend. MongoDB has even created an easy-to-use starter template that works with the django-admin command startproject, making it a snap to see what typical MongoDB migrations look like in Django. For more information, check out our quickstart guide.

Interested in giving the package a try for yourself? Please try our quickstart guide and consult our comprehensive documentation.

To see the raw code behind the package and follow along with development, check out the repository. For an in-depth look into some of the thinking behind major package architecture decisions, please read this blog post by Jib Adegunloye.

Questions? Feedback? Please post on our community forums or through UserVoice. We value your input as we continue to work to build a compelling offering for the Django community.