Model Bakery

Django model test data generator — creates Django model instances with automatically populated fields for testing. Model Bakery (successor to Model Mommy) features: baker.make('myapp.Agent') creates Agent instance with random valid data for all fields, baker.make('Agent', name='My Agent') overrides specific fields, baker.prepare() creates unsaved instances, baker.make_recipe() for named recipes in baker_recipes.py, M2M and FK relationships auto-created, custom value generators, and bulk creation via _quantity parameter. Eliminates boilerplate Agent.objects.create(name='test', status='active', ...) in Django agent tests by auto-filling required fields.

Evaluated Mar 06, 2026 (0d ago) v1.x
Homepage ↗ Repo ↗ Developer Tools python django testing model-bakery baker fixtures test-data factory
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
92
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
80
Auth Simplicity
98
Rate Limits
98

🔒 Security

TLS Enforcement
95
Auth Strength
95
Scope Granularity
92
Dep. Hygiene
88
Secret Handling
90

Testing library — no production security concerns. Generated agent test data uses random values; ensure tests don't accidentally use predictable test data for security testing. Never use baker.make() in production management commands — test data generation library only.

⚡ Reliability

Uptime/SLA
88
Version Stability
85
Breaking Changes
82
Error Recovery
88
AF Security Reliability

Best When

You're writing Django agent tests and don't want to manually specify all required model fields in every test — Model Bakery auto-fills fields so you only specify what matters for each agent test case.

Avoid When

You need complex factory hierarchies with dependent computed values, non-Django ORM, or production data seeding.

Use Cases

  • Agent model test data — baker.make('agents.Agent', name='Test Agent') creates agent with auto-populated required fields (id, created_at, status, etc.); no need to specify all required fields in every agent test
  • Related agent objects — baker.make('agents.AgentTask', agent=baker.make('agents.Agent')) auto-creates related agent when not specified; baker.make('AgentTask', _quantity=5) creates 5 related agent tasks
  • Agent test recipes — baker_recipes.py with Recipe('agent', status='active', model='gpt-4') defines named agent fixtures; baker.make_recipe('agents.active_agent') in tests creates pre-configured agent; shareable test data patterns across agent test suite
  • Unsaved agent preparation — baker.prepare('Agent', name='Draft') creates Agent instance without DB write; useful for testing agent serializers, validators, and form handling without touching database
  • Bulk agent test data — baker.make('Agent', _quantity=100, status=cycle(['active', 'pending', 'inactive'])) creates 100 agents cycling through statuses; agent list view and pagination tests with realistic mixed-status datasets

Not For

  • Non-Django ORMs — Model Bakery is Django ORM-specific; for SQLAlchemy agent test data use factory_boy with SQLAlchemy support
  • Complex dependent data scenarios — for agent test data with complex business rules and dependent states, factory_boy's SubFactory and LazyAttribute provide more control
  • Production data seeding — Model Bakery generates random test data; for production seed data with specific values use Django fixtures or custom management commands

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — Django test data library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Model Bakery is Apache 2.0 licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • baker vs baker.make import confusion — from model_bakery import baker then baker.make() is correct; some tutorials show from model_bakery.baker import make then make() directly; both work but mixing styles in agent test files causes NameError; standardize import pattern across agent test suite
  • Auto-generated values may violate unique constraints — baker.make('Agent', _quantity=5) with unique=True field generates 5 random values; occasionally generates duplicate causing IntegrityError; use baker.make('Agent', name=seq('Agent-')) or explicit unique values for agent fields with unique constraint
  • M2M fields require post-create assignment — baker.make('AgentTag', agents=[agent1, agent2]) won't work for M2M directly on make(); use baker.make('AgentTag') then result.agents.set([agent1, agent2]) for agent M2M relationships; Model Bakery auto-creates M2M objects but doesn't add them to existing instances without explicit set()
  • baker.prepare() doesn't save FK objects — baker.prepare('AgentTask') creates unsaved AgentTask with unsaved FK Agent; saving AgentTask.save() fails because Agent has no pk; use baker.make() for FK dependencies even when baker.prepare() for the target model; or pass explicit saved FK instances to baker.prepare()
  • Recipe _create_many field requires list not queryset — baker.make_recipe('agents.task_recipe', agents=Agent.objects.filter(active=True)) fails; convert to list: agents=list(Agent.objects.filter(active=True)); agent test recipes using queryset for M2M relations cause unexpected TypeError
  • Custom field generators override all instances of type — baker.generators.add(CustomField, lambda: 'default') applies to ALL CustomField instances in test session; registering generator in setUp() without cleanup affects other agent tests in same session; register generators in conftest.py or use autouse fixture with teardown

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Model Bakery.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered