Djongo - Django MongoDB Connector

raw JSON →
1.3.7 verified Fri May 01 auth: no python maintenance

Djongo is a MongoDB connector for Django that allows you to use MongoDB as your backend database with the Django ORM. It works by translating Django ORM queries into MongoDB-compatible ones. Current version: 1.3.7. Release cadence: sporadic, last release in 2021.

pip install djongo
error django.core.exceptions.ImproperlyConfigured: 'djongo' isn't an available database backend.
cause Djongo not installed or not added to INSTALLED_APPS in older versions.
fix
Run 'pip install djongo' and ensure 'djongo' is in INSTALLED_APPS.
error ModuleNotFoundError: No module named 'djongo'
cause Djongo package not installed.
fix
Install with: pip install djongo
error django.db.utils.OperationalError: no such table: ...
cause Djongo does not support migrations with SQL-style table creation. It works collection-based.
fix
Run 'python manage.py migrate' to create collections (but it may not create tables). Use 'python manage.py makemigrations' only if you have models.
breaking Djongo is not compatible with Django 4.x or later. It relies on internal Django APIs that changed in Django 4. Use Django 3.2 or earlier.
fix Downgrade Django to 3.2 LTS or consider alternative like mongoengine.
gotcha Djongo does not support all Django ORM queries. Complex joins, subqueries, and some aggregation may fail or produce incorrect results.
fix Test queries thoroughly; fallback to raw MongoDB queries via PyMongo if needed.
deprecated The djongo project is in maintenance mode and no longer actively developed. No updates since 2021.
fix Consider migrating to a more active MongoDB-Django connector like beanie, mongoengine, or motor.

Configure Django to use MongoDB via djongo as the database engine.

# settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'djongo', # add djongo
]

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        'NAME': 'your-db-name',
        'ENFORCE_SCHEMA': True,
        'CLIENT': {
            'host': os.environ.get('MONGO_HOST', 'localhost'),
            'port': int(os.environ.get('MONGO_PORT', 27017)),
            'username': os.environ.get('MONGO_USER', ''),
            'password': os.environ.get('MONGO_PASS', ''),
        }
    }
}