Framework
Seed Django + Supabase with MockHero
Command
# app/management/commands/seed.py
import os, requests
from django.core.management.base import BaseCommand
from app.models import Profile, Post
class Command(BaseCommand):
def handle(self, *args, **kwargs):
body = {
"tables": [
{"name": "profiles", "count": 40, "fields": [
{"name": "id", "type": "uuid"},
{"name": "full_name", "type": "full_name"}
]},
{"name": "posts", "count": 200, "fields": [
{"name": "id", "type": "uuid"},
{"name": "user_id", "type": "ref", "ref": "profiles.id"},
{"name": "title", "type": "sentence"}
]}
]
}
data = requests.post(
"https://api.mockhero.dev/api/v1/generate", json=body,
headers={"x-api-key": os.environ["MOCKHERO_API_KEY"]}
).json()
Profile.objects.bulk_create([Profile(**p) for p in data["profiles"]])
Post.objects.bulk_create([Post(**p) for p in data["posts"]])
Run with python manage.py seed.
Get Started
M
MockHero Team
Guides and tutorials for generating realistic test data with the MockHero API.
Start generating test data for free
1,000 rows/month on the free tier. No credit card required.
Get Your API Key