A Django database backend and admin integration for Amazon DynamoDB.
Project description
Django DynamoDB Backend
A Django database backend and admin integration for Amazon DynamoDB. Run Django 100% on DynamoDB — no PostgreSQL, MySQL, or SQLite required.
Features
- 100% DynamoDB: Run Django without any relational database — sessions, users, and admin all on DynamoDB.
- DynamoDB authentication: Full user auth system with username/email GSIs, password hashing, and permissions.
- DynamoDB sessions: Session backend with automatic TTL-based expiration.
- Django Admin: Complete admin interface support with DynamoDB-specific optimizations.
- Django ORM compatible: Familiar QuerySet API,
Qobjects, aggregations, and more. - Migration system: DynamoDB-specific table and index management.
- Cost optimized: Pay-per-request billing, fits within the AWS free tier for development.
- Serverless ready: Suitable for AWS Lambda deployments.
Requirements
- Python 3.11+
- Django 5.2+
boto3,pynamodb(installed automatically)
Installation
pip install django-dynamodb-backend
This is currently a release candidate. If pip is selecting an older final release, pass --pre:
pip install --pre django-dynamodb-backend
Configuration
DynamoDB-only mode (recommended)
Run Django entirely on DynamoDB — ideal for serverless deployments:
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth", # Required for admin
"django.contrib.contenttypes",
"django.contrib.sessions", # Required for session middleware
"django.contrib.messages",
"django.contrib.staticfiles",
"django_dynamodb_backend",
"django_dynamodb_backend.contrib.auth_dynamo", # DynamoDB users
]
DATABASES = {
"default": {
"ENGINE": "django_dynamodb_backend.db",
"NAME": "my_app",
"OPTIONS": {
"region_name": "us-east-1",
# For local development against DynamoDB Local / LocalStack:
# "endpoint_url": "http://localhost:8000",
# "aws_access_key_id": "test",
# "aws_secret_access_key": "test",
},
}
}
# Sessions stored in DynamoDB with TTL
SESSION_ENGINE = "django_dynamodb_backend.sessions"
DYNAMODB_SESSION_TABLE_NAME = "django_sessions"
# Authentication backed by DynamoDB with GSIs on username and email
AUTH_USER_MODEL = "auth_dynamo.DynamoUser"
DYNAMODB_USER_TABLE_NAME = "django_users"
AUTHENTICATION_BACKENDS = [
"django_dynamodb_backend.contrib.auth_dynamo.backends.DynamoAuthBackend",
]
Create tables
# Sessions table (with TTL)
python manage.py dynamodb_create_session_table
# Users table (with GSIs); optionally seed an admin user
python manage.py dynamodb_create_user_table --create-admin
# Or create a superuser interactively (like Django's createsuperuser)
python manage.py dynamodb_createsuperuser
# Your app's tables
python manage.py dynamodb_migrate
Hybrid mode
Use DynamoDB for your application models while keeping PostgreSQL/SQLite for Django's built-in apps:
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_dynamodb_backend",
]
DATABASES = {
"default": {
"ENGINE": "django_dynamodb_backend.db",
"NAME": "my_app",
"OPTIONS": {"region_name": "us-east-1"},
}
}
Defining models
from django.db import models
from django_dynamodb_backend.models import DynamoDBModel
class BlogPost(DynamoDBModel):
id = models.CharField(primary_key=True, max_length=36)
title = models.CharField(max_length=200)
content = models.TextField()
author = models.CharField(max_length=100)
published = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "blog_posts"
def __str__(self):
return self.title
Admin integration
from django.contrib import admin
from django_dynamodb_backend.admin import DynamoDBAdmin
from .models import BlogPost
@admin.register(BlogPost)
class BlogPostAdmin(DynamoDBAdmin):
list_display = ["title", "author", "published", "created_at"]
list_filter = ["published", "author"]
search_fields = ["title", "content"]
Management commands
| Command | Description |
|---|---|
dynamodb_create_session_table |
Create the sessions table with TTL |
dynamodb_create_user_table |
Create the users table with GSIs |
dynamodb_create_user_table --create-admin |
Also create an admin user |
dynamodb_createsuperuser |
Create a superuser interactively |
dynamodb_migrate |
Apply DynamoDB migrations |
dynamodb_makemigrations |
Create new migrations |
dynamodb_showmigrations |
Show migration status |
dynamodb_rollback |
Roll back migrations |
dynamodb_performance |
Monitor DynamoDB performance metrics |
DynamoDB table schemas
Sessions table (django_sessions)
- Partition key:
session_key(String) - TTL attribute:
expire_date(Unix timestamp) - Billing: Pay-per-request
Users table (django_users)
- Partition key:
id(String, UUID) - GSI
username-index: lookup by username - GSI
email-index: lookup by email - Billing: Pay-per-request
Documentation
Full documentation lives in the docs/ directory on GitHub:
| Document | Description |
|---|---|
| Documentation Index | Map of all docs and reading paths |
| Architecture | How the pieces fit together |
| Migration Tutorial | Step-by-step guide to migrate existing Django projects |
| Django Compatibility | Supported ORM features and limitations |
| API Reference | Complete API documentation |
| Deployment Guide | Production and AWS Lambda deployment |
| Feature Walkthrough | Detailed feature guide with examples |
| Demo | Run the bundled demo project locally |
Contributing
Contributions welcome — see CONTRIBUTING.md for development setup, testing, and the pull request workflow.
License
MIT — see LICENSE.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_dynamodb_backend-1.0.0.tar.gz.
File metadata
- Download URL: django_dynamodb_backend-1.0.0.tar.gz
- Upload date:
- Size: 107.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e6b38bdfce2ccbcde572439006068ae138830a4d94360553ea556c72c9d82a5
|
|
| MD5 |
90e9ca35bfcdf0cb5bfbb25eb61ef10f
|
|
| BLAKE2b-256 |
c5a828233f92c08a12526c81fe27c08e15edd2d464882cf2e4b4cd2d892d6ca5
|
Provenance
The following attestation bundles were made for django_dynamodb_backend-1.0.0.tar.gz:
Publisher:
release.yml on jpwhite3/django-dynamodb-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_dynamodb_backend-1.0.0.tar.gz -
Subject digest:
1e6b38bdfce2ccbcde572439006068ae138830a4d94360553ea556c72c9d82a5 - Sigstore transparency entry: 1615932706
- Sigstore integration time:
-
Permalink:
jpwhite3/django-dynamodb-backend@16ba4f0ca38e0ad14193bc97e05c1be7922df6ac -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jpwhite3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@16ba4f0ca38e0ad14193bc97e05c1be7922df6ac -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_dynamodb_backend-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_dynamodb_backend-1.0.0-py3-none-any.whl
- Upload date:
- Size: 107.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8728250f01a6cda0c6762cde27521a779a2a933a6a87cccb6b7c399f9a5e2454
|
|
| MD5 |
6475e8b9a4ce089ef2d6fd34ff9b8974
|
|
| BLAKE2b-256 |
8ec8e933444518e558404bb701055915b12a19205317cd42a8c51241bce7baf0
|
Provenance
The following attestation bundles were made for django_dynamodb_backend-1.0.0-py3-none-any.whl:
Publisher:
release.yml on jpwhite3/django-dynamodb-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_dynamodb_backend-1.0.0-py3-none-any.whl -
Subject digest:
8728250f01a6cda0c6762cde27521a779a2a933a6a87cccb6b7c399f9a5e2454 - Sigstore transparency entry: 1615932711
- Sigstore integration time:
-
Permalink:
jpwhite3/django-dynamodb-backend@16ba4f0ca38e0ad14193bc97e05c1be7922df6ac -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jpwhite3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@16ba4f0ca38e0ad14193bc97e05c1be7922df6ac -
Trigger Event:
push
-
Statement type: