model-bakery
Smart object creation facility for Django.
What it is and what it does
Model Bakery is a Django testing utility that automatically generates model instances with realistic, randomized data. Instead of manually constructing test objects with all required fields, you call baker.make() with a model name or class and receive a fully populated, saved instance. It introspects your model's fields and generates appropriate values—integers for IntegerField, email addresses for EmailField, dates for DateField, and so on—eliminating boilerplate in test setup.
The package is designed for developers writing Django unit tests who need quick, realistic fixtures without writing verbose factory code. It follows Django and Python release cycles, supporting current versions of both. With a single runtime dependency (django) and low install friction, it integrates directly into your test suite.
Use it for:
- Rapidly populate test databases with valid model instances during unit test setup.
- Generate test data for integration tests without manually specifying every field value.
- Create related object hierarchies in tests with minimal code.
- Prototype and validate Django model schemas during development.
- Reduce test boilerplate when testing model methods and business logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Model Bakery creates test fixtures for Django models automatically, generating realistic data for object instances with a single line of code.
Yes. Model Bakery is actively maintained, has no known vulnerabilities, carries a permissive license, and solves a real pain point in Django testing. The low install friction and single dependency make it a safe, practical addition to any Django project's test suite.
Install
model-bakery on PyPI
pip
pip install model-bakeryuv
uv add model-bakerypoetry
poetry add model-bakeryInstalling model-bakery
Before you install
Low install friction; pure Python wheel with only django as a runtime dependency. Actively maintained with a recent release and steady commit history.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install model-bakery
from model_bakery import baker
# In a test
customer = baker.make('shop.Customer')
print(customer.name) # auto-generated value
Requires Django to be installed; requires Python 3.10 or later.
Verify before relying
- Whether the package supports custom field generation strategies beyond the built-in defaults.
- Performance characteristics when creating large numbers of related objects.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — django |
| Maintenance | actively maintained — 52 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,076,886/month — #3,311 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: model_bakery-1.24.0-py3-none-any.whl
Keywords: django, factory, python, testing
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
model-mommyModel Mommy generates Django model instances…
permissive · top 15,000 on PyPI
django-ordered-modelAdds ordering and reordering capabilities to…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI
fontbakeryFont Bakery is a command-line tool that checks…
unclear · top 15,000 on PyPI
pytest-factoryboyIntegrates factory_boy with pytest to register…
permissive · top 5,000 on PyPI
pytest-rabbitmqA pytest plugin that provides fixtures to start…
copyleft · top 15,000 on PyPI
pytest-casespytest-cases lets you separate test case data…
permissive · top 5,000 on PyPI
factory-boyfactory_boy replaces static test fixtures with…
permissive · top 1,000 on PyPI
fixturesProvides a reusable fixture contract for unit…
permissive · top 15,000 on PyPI