django-dynamic-fixture
A full library to create dynamic model instances for testing purposes.
What it is and what it does
Django Dynamic Fixture (DDF) is a test-data generation library that creates Django model instances on demand, saving you from writing repetitive fixture code. Instead of manually constructing test objects with all their required fields, you call G(Model) to generate a valid instance with sensible random defaults, then override only the fields that matter for your test. It handles relationships, foreign keys, and nested object creation through a simple dot-notation syntax, and provides utilities like M() for masked random strings and teach() to define reusable generation rules.
The library is designed to keep test code readable and maintainable by letting you focus on test logic rather than data setup. It works with Django's ORM directly and integrates into your existing test suite without special configuration.
Use it for:
- Writing unit tests for Django models where you need valid instances but don't care about most field values
- Creating related objects in tests without nested fixture boilerplate
- Generating multiple test instances quickly for bulk test data
- Testing model methods and querysets where the test logic matters more than the data setup
- Defining reusable test data patterns across a test suite using teach() to configure model generation rules
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Creates dynamic Django model instances for testing without manual fixture setup, letting you generate test data with minimal boilerplate.
Yes, if you write Django tests. DDF has no runtime dependencies, low install friction, and a stable track record since its first release in 2011. The dormant maintenance status is acceptable for a mature library—it does one thing well and doesn't require frequent updates. Install it if you want to reduce test boilerplate; skip it only if your project uses minimal fixtures or a different test-data strategy.
Install
django-dynamic-fixture on PyPI
pip
pip install django-dynamic-fixtureuv
uv add django-dynamic-fixturepoetry
poetry add django-dynamic-fixtureInstalling django-dynamic-fixture
Before you install
Low friction install with no runtime dependencies. Maintenance is dormant—last release was Sep 2023 and last commit Oct 2024—but the package is stable and widely used. Suitable for established projects that don't require active development.
License in practice
MIT license is permissive; you can use this in commercial and open-source projects with minimal restrictions.
Quickstart
pip install django-dynamic-fixture
from ddf import G
author = G(Author)
book = G(Book, authors=[author])
Requires Django to be installed and configured in your project; DDF generates instances for Django models only.
Verify before relying
- Whether the package works with Django versions released after Oct 2024
- Compatibility with Python 3.12+ (classifiers list only up to 3.11)
- Monthly download volume and its stability over time
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,064 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 162,576/month — #10,596 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_dynamic_fixture-4.0.1-py3-none-any.whl
Keywords: python, django, testing, fixture
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
pytest-unused-fixturesA pytest plugin that identifies and reports…
permissive · top 15,000 on PyPI
pytest-factoryboyIntegrates factory_boy with pytest to register…
permissive · top 5,000 on PyPI
pytest-lazy-fixturesAllows you to reference pytest fixtures…
permissive · top 5,000 on PyPI
django-phonenumber-fieldProvides a Django model field for storing,…
permissive · top 5,000 on PyPI
django-fixture-magicProvides Django management commands to dump…
permissive · top 15,000 on PyPI
pytest-lazy-fixtureAllows you to use pytest fixtures directly as…
permissive · top 15,000 on PyPI
pytest-fixture-configProvides configuration objects and decorators…
permissive · top 15,000 on PyPI
marshmallow-sqlalchemyGenerates marshmallow schemas from SQLAlchemy…
permissive · top 5,000 on PyPI
pytest-postgresqlA pytest plugin that provides fixtures to…
copyleft · top 5,000 on PyPI
pytest-rngProvides pytest fixtures that make random…
permissive · top 15,000 on PyPI