Skip to content

Seed Data Guide

This guide covers managing seed data for development and testing.

Catalog Manager

The Django admin includes a Catalog Manager GUI for importing/exporting product data.

Access at: http://localhost:8000/admin/products/catalog/

Export Catalog

  1. Go to Catalog Manager
  2. Click "Export Catalog"
  3. Download the generated YAML file

Import Catalog

  1. Go to Catalog Manager
  2. Upload a YAML file
  3. Review the import preview
  4. Confirm the import

YAML Format

# catalog.yaml
categories:
  - name: T-Shirts
    slug: t-shirts
    children:
      - name: Short Sleeve
        slug: short-sleeve

colors:
  - name: Zwart
    hex_code: "#000000"
  - name: Wit
    hex_code: "#FFFFFF"

sizes:
  - name: S
    type: clothing
    chest_width: 91
    body_length: 69
  - name: M
    type: clothing
    chest_width: 97
    body_length: 72

products:
  - name: Classic T-Shirt
    slug: classic-t-shirt
    sku: TSHIRT-001
    category: t-shirts/short-sleeve
    base_price: 24.95
    variants:
      - color: Zwart
        size: S
        stock: 100
      - color: Zwart
        size: M
        stock: 150

Django Fixtures

Load Fixtures

python manage.py loaddata fixtures/sample_data.json

Create Fixtures

python manage.py dumpdata products.Category products.Product \
  --indent 2 > fixtures/products.json

Test Data Script

python create_test_data.py

Creates: - Sample categories - Sample products with variants - Sample designs - Test user accounts

Database Reset

Development Only

This destroys all data!

python manage.py flush
python manage.py migrate
python manage.py loaddata fixtures/sample_data.json
python manage.py createsuperuser