Generate Django test data from your models
Hand-written Django fixtures and factory_boy factories rot the moment you run a migration, and copying a production dump into your test suite is a GDPR problem waiting to happen. The fix: SeedBase reads your models.py and generates realistic, foreign-key-consistent data that actually looks real, not "Premium Widget 1" and lorem ipsum. One fixture seeds a whole test database, with pytest and pytest-django.
Free tier, no card. Want to see the output before wiring anything up? Try the login-free sandbox: paste a schema, generate, look at the rows.
From models.py to a populated test database
A handful of Django fixtures is fine. A real project is not. Once you have dozens of models, every factory has to know which parent rows exist, which foreign keys to satisfy, and which derived totals to keep in sync. You end up maintaining a second, worse copy of your schema in test code, and it breaks on the next migration.
SeedBase reads your models.py instead. It walks the model graph, resolves the foreign keys, and fills a whole foreign-key-consistent database with realistic distributions. One generation, one fixture, and your test gets a database that looks like production without being production.
- Every
customer_idpoints at a customer that exists, so the data loads with constraints on. - Realistic distributions and values, not "Premium Widget 1", so your assertions test against data that looks real.
- One fixture replaces the pile of per-model factory_boy factories and the wiring between them.
- No production data leaves the building, so there is no GDPR exposure in the test suite.
Seed a Django test database in pytest
A pytest fixture is just dependency injection: the test declares what it needs in its arguments and the framework provides it. So inject the whole database.
# tests/test_orders.py
def test_pagination(seeded_database):
# a live connection to a DB full of realistic, FK-consistent data
rows = seeded_database.execute(
sqlalchemy.text("SELECT email FROM users LIMIT 5")
).fetchall()
assert all("@" in e for (e,) in rows)
Install with pip install "seedbase[database]". The seeded_database fixture loads a generation into a live database and hands you the connection. Prefer no database at all? The seeded_rows fixture returns {table: [rows]} as an in-memory dict, so you assert against the rows directly. It plays alongside pytest-django, and it is an alternative to loaddata and factory_boy when you want a whole populated database rather than a handful of objects.
Reads real Django projects
Toy schemas are easy. The hard part is the patterns a real Django codebase actually uses, and that is what SeedBase was built against.
- Abstract mixins: a
TimeStampedModelbase withcreated_atandupdated_atinherited across half your models. - Model inheritance: concrete and abstract bases resolved into the right tables.
ForeignKey("self"): self-referential trees and graphs, like a category that has a parent category.- Implicit
idprimary keys: the auto-addedidfield that never shows up in models.py but is real in the database.
SeedBase was tested against a real 20-app Django project with 226 tables, including abstract mixins and ForeignKey("self"). That is where the foreign-key handling and the edge cases came from, not from a tidy three-table demo.
Deterministic and reproducible
Generation is seeded. The same seed produces the same data, every run. That keeps CI reproducible: the same fixture yields the same rows on every machine, so a green build stays green for the right reason. When a test fails, reuse the seed and you reproduce the exact dataset that broke it, instead of chasing a fixture that has since been hand-edited.
Free tier: generate, download, seed
Generation and JSON download are free to use. You do not need push-to-database or any paid feature to seed a Django test database, because the data loads through your own database connection or as plain rows in memory. Generate once, download the JSON, and let your fixture wire it into the test setup.
ForeignKey("self"), that is where the foreign-key and edge-case handling came from. EU-hosted, no third-party trackers, and you can export everything, so nothing is locked in.Try it
There is a runnable example, so you can clone, run the test, and watch a real FK-consistent dataset get seeded into a Django test database. Then point it at your own models.
- Clone the runnable example under
examples/pytest/, run the test, and watch the fixture seed a live database. - Paste a schema and look at the rows in the login-free sandbox, no account needed.
- Drive generation from your editor with the VS Code extension or the JetBrains plugin.
- Read the docs for the pytest fixtures and the model-reading details.
- On another stack? See the Symfony test data and Laravel test data guides, or the test data fixtures hub.
Stop hand-maintaining Django fixtures.
Generate a foreign-key-consistent dataset from your models.py once and seed it into your pytest tests. Free tier, no card.
Create a free accountMore: login-free sandbox · VS Code · Fixtures hub · Docs · home
Frequently asked questions
Is it free?
Yes. Generation and JSON download are part of the free tier, so you can pull a foreign-key-consistent dataset from your Django models and load it into your tests at no cost. Pro adds Parquet export, direct database push and higher row limits, but you do not need any of that to seed a Django test database.
How is this different from factory_boy or Faker?
factory_boy and Faker generate objects or values one field at a time and you still wire up every factory and relationship by hand. SeedBase reads your schema and fills a whole foreign-key-consistent database with realistic distributions, so an order that points at a customer actually has a customer to point at and the values look real instead of "Premium Widget 1" or lorem ipsum.
Does it read my models.py?
Yes. SeedBase reads a Django models.py including abstract mixins and model inheritance, ForeignKey("self") self-references, and implicit id primary keys. It also reads a SQL dump or a live database connection, so you can point it at whichever representation of the schema you already have.
Is it deterministic?
Yes. Generation is seeded, so the same seed produces the same data every run. That makes CI reproducible: the same fixture yields the same rows, and a failing test can be reproduced exactly by reusing the seed.
Does it work with pytest-django?
Yes. The seeded_database fixture loads a generation into a live database and hands your test a connection, and it plays alongside pytest-django. If you do not want a database at all, the seeded_rows fixture returns the data as an in-memory dict of table to list of rows. It is an alternative to loaddata and factory_boy for a whole populated database.