Django test data, FK-consistent, straight from your models.py.
Paste or push your models.py and get a populated database where every ForeignKey resolves. Abstract base classes, mixin inheritance, ForeignKey("self") and Django's implicit id PKs are handled, tested against a real 20-app project with 226 models.
Free tier · no card · EU-hosted · zero trackers
Also for: Prisma test data · SQL test data · GDPR anonymization
From Django schema to populated database
Paste your models.py in the web app, push your whole project with the VS Code or PyCharm plugin, or use the CLI. The parser resolves Django's inheritance chain transitively: abstract bases merge their fields into every child, mixin-only models are detected, and the implicit auto id primary key is added so foreign keys have something to point at.
class Beehive(TimestampMixin, SoftDeleteMixin):
name = models.CharField(max_length=120)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
# → INSERT INTO "user" ... 200 rows
# → INSERT INTO "beehive" ... owner_id resolves (declared FK),
# 2-19 hives per owner, long-tail distributedWhat you get
Every foreign key resolves
Children reference parents that exist, including self-references (parent_id) and one-to-one relations. Inserts come out in topological order, so the SQL loads into a constrained schema as-is.
Production-like distributions
Not every user has exactly 5 orders: long-tail and normal distributions create the skew where pagination and N+1 bugs actually show up.
Time-aware data
Timestamps generate relative to today, "last 30 days" dashboards stay populated instead of going empty as fixtures age.
Deterministic per seed
Same seed, same data, reproducible CI runs. Export the generation config as JSON and commit it next to your migrations.
VS Code & PyCharm plugins
Push every models.py in your project to SeedBase in one click, the schema lands parsed and ready to generate.
Generate Django test data from models.py or a live database
Point SeedBase at your schema once, then generate from the Python SDK or the CLI. The SDK reads the project you imported (parsed from models.py or introspected from a live Postgres or MySQL database), produces FK-consistent rows, and hands you back SQL, CSV or JSON, or pushes straight into a connection.
# pip install seedbase
from seedbase import SeedbaseClient
client = SeedbaseClient(token="dr_sk_...")
# project_id was created when you imported models.py (or a live DB URL)
gen = client.generate(project_id, seed=42, wait=True)
# SQL with INSERTs in topological FK order, loads into a constrained schema as-is
sql = client.download(gen["id"], fmt="sql")
open("seed.sql", "w").write(sql)
Prefer the terminal? The CLI pulls schema and data straight into your local database, no SQL file to shuffle around.
# schema + data into the database from .seedbase.json
seedbase login
seedbase init
seedbase pull all --drop
Exact flags and the full command reference live in the docs.
pytest fixture with a reproducible seed
The Python package ships a pytest plugin. A fixed seed means the same rows on every run, so a failing test reproduces locally with the identical dataset and snapshot assertions stay stable. This is dependency injection of test data, not per-model factories you write and maintain by hand.
# conftest.py, or rely on the bundled fixture
import pytest
from seedbase import SeedbaseClient
@pytest.fixture(scope="session")
def seeded_data():
client = SeedbaseClient(token="dr_sk_...")
gen = client.generate(project_id, seed=42, wait=True)
return client.download(gen["id"], fmt="json")
def test_owner_has_hives(seeded_data):
# same seed, same rows, every CI run
assert seeded_data["beehive"]
assert all(h["owner_id"] for h in seeded_data["beehive"])
A pinned reference_date makes timestamps reproducible too, so "last 30 days" queries return the same window across runs instead of drifting as the calendar moves. factory_boy and Faker remain a good fit for building single objects inside a test, SeedBase fills a whole referentially intact database around them.
Foreign-key consistency across many tables
A real Django project is not three tables. Abstract bases, mixins, swappable user models and chains of ForeignKey and OneToOneField stack up fast. SeedBase walks the whole dependency graph, generates parents before children, and emits inserts in topological order so nothing references a row that does not exist yet. Self-references build trees rather than dangling pointers.
# orders depend on customers, customers on regions ...
# SeedBase orders the writes so every *_id resolves
INSERT INTO "region" ... # 20 rows
INSERT INTO "customer" ... # 200 rows, region_id resolves
INSERT INTO "order" ... # 1,800 rows, customer_id resolves, 0-30 per customer
INSERT INTO "orderitem" ... # order_id + product_id both resolve
This was tested against a real 20-app Django project with 226 models, abstract bases and self-referencing foreign keys included, so the parser is not a toy that handles only flat schemas. The same FK-safe ordering applies whether you export raw SQL for PostgreSQL and MySQL or generate for a Prisma schema. Masking production data instead of synthesizing it? See GDPR-compliant anonymization.
Django test data FAQ
Does it handle abstract models and mixins?
Yes. Abstract base classes (Meta: abstract = True) don't become tables, but their fields merge into every inheriting model, including models that inherit only from mixins and never mention models.Model directly.
What about ForeignKey("self")?
Self-referencing foreign keys generate trees: rows reference earlier rows of the same table, nullable self-FKs get NULL roots, and there are no forward references, the SQL loads row by row with constraints enabled.
How is this different from factory_boy?
factory_boy generates objects inside a test run, the right tool for pytest fixtures. SeedBase produces a dataset (SQL/CSV/JSON) for dev databases, staging, demos and CI containers, without writing or maintaining per-model factories. More on the library comparison →
Can I load the data into Postgres or MySQL directly?
Yes, download SQL/CSV/JSON or push directly into a Postgres/MySQL connection. Inserts are emitted in topological FK order, so constrained schemas load without reordering.
Can I generate Django test data from a live database instead of models.py?
Yes. SeedBase reads either your models.py or a live Postgres/MySQL database by introspecting its tables, columns and relations. Either way you get a project you can generate FK-consistent rows against, from the web app, the CLI, or the Python SDK.
How do I get a reproducible pytest fixture?
The Python package ships a pytest plugin and the SDK accepts a seed. Pass the same seed and you get the same rows on every run, so a failing test reproduces locally with the identical dataset. A pinned reference_date keeps timestamps reproducible too, so date-window queries return the same range across runs.
Does it keep foreign keys consistent across many tables?
Yes. SeedBase walks the full dependency graph, generates parents before children, and emits inserts in topological order so every foreign key resolves. Self-references build trees rather than dangling pointers. It was tested against a real 20-app Django project with 226 models.
Two minutes to a fully populated database
Sign up, import your schema, generate. No sales call, no credit card, the free tier is enough for a real first impression.
- FK-consistent
- Realistic distributions
- SQL / CSV / JSON
- EU-hosted
Other stacks: Prisma seed data · SQL test data · Compare: vs Faker · vs Snaplet · GDPR anonymization · Docs