Data Import & Export
This guide covers all management commands for importing and exporting data across the application.
Command Overview
Commands are organized by domain. All import commands support --dry-run for previewing changes. Most export commands support --dir for custom output paths.
Diffusion
Command |
Description |
|---|---|
|
Sync |
|
Export models and LoRAs from database to JSON |
|
Bulk import diffusion prompts |
|
Export prompts to file |
|
Pre-download models to HuggingFace cache |
Core
Command |
Description |
|---|---|
|
Import LLM prompt templates from |
|
Export active templates to JSON |
|
Import regions, countries, languages, LLM models from |
|
Export reference data to separate JSON files |
Audiences
Command |
Description |
|---|---|
|
Import audience segments from |
|
Export segments to JSON |
|
Import personas from |
|
Export personas and persona-segment mappings |
TV Spots
Command |
Description |
|---|---|
|
Import brand data from |
|
Export brands to JSON |
|
Import a TV spot from a JSON file (creates Campaign + origin VideoAdUnit) |
|
Import adaptations JSON into prompts and jobs |
Import Dependency Order
When setting up a new environment, import data in this order:
# 1. Core reference data (dependency-ordered internally)
uv run manage.py import_reference_data
# 2. Prompt templates
uv run manage.py import_prompt_templates
# 3. Diffusion presets (models and LoRAs)
uv run manage.py import_presets
# 4. Audience segments (no dependencies)
uv run manage.py import_segments
# 5. Personas (depends on segments + reference data)
uv run manage.py import_personas
# 6. Brands (no dependencies)
uv run manage.py import_brands
# 7. TV spots (depends on reference data for language lookup)
uv run manage.py import_tvspot data/example_tvspot.json
The import_reference_data command handles its own internal dependencies: LLM Models → Regions → Countries → Languages → M2M mappings.
Common Options
--dry-run
Preview what would change without creating or modifying records:
uv run manage.py import_reference_data --dry-run
uv run manage.py import_prompt_templates --dry-run
uv run manage.py import_segments --dry-run
uv run manage.py import_personas --dry-run
uv run manage.py import_brands --dry-run
uv run manage.py import_tvspot data/spot.json --dry-run
--dir
Export to or import from a custom directory (instead of the default data/):
uv run manage.py export_reference_data --dir backups/2024-02/
uv run manage.py export_prompt_templates --dir backups/2024-02/
uv run manage.py export_segments --dir backups/2024-02/
uv run manage.py export_personas --dir backups/2024-02/
uv run manage.py export_brands --dir backups/2024-02/
Data Files
All configuration files live under data/:
File |
Contents |
|---|---|
|
Diffusion models and LoRA configurations |
|
LLM prompt templates (Jinja2) |
|
LLM model configurations |
|
Geographic regions |
|
Countries with default language references |
|
Languages with primary LLM model references |
|
Country-to-Region M2M mappings |
|
Country-to-Language M2M mappings |
|
Audience segments (demographic, behavioral, psychographic) |
|
Persona records with geographic references |
|
Persona-to-Segment M2M mappings |
|
Brand reference data |
|
Example TV spot JSON for testing imports |
Backup & Restore
To create a complete backup:
mkdir -p backups/$(date +%Y-%m-%d)
uv run manage.py export_presets
uv run manage.py export_prompt_templates --dir backups/$(date +%Y-%m-%d)/
uv run manage.py export_reference_data --dir backups/$(date +%Y-%m-%d)/
uv run manage.py export_segments --dir backups/$(date +%Y-%m-%d)/
uv run manage.py export_personas --dir backups/$(date +%Y-%m-%d)/
uv run manage.py export_brands --dir backups/$(date +%Y-%m-%d)/
To restore from backup, import in dependency order using the --dir option where supported.