CLI Commands
The django_generator module provides the gen management command for client generation.
It reads your project’s generation.py and generates all configured targets.
Basic Usage
# Generate all configured targets (all languages)
python manage.py genPlatform Selection
# TypeScript only
python manage.py gen --ts
# Python only
python manage.py gen --py
# Go only
python manage.py gen --go
# Swift only
python manage.py gen --swiftMultiple flags combine — only the selected languages are generated:
# TypeScript and Python, skip Go/Swift
python manage.py gen --ts --pyTarget Filtering
Filter by the type field defined in your Target config:
# Only admin targets
python manage.py gen --target admin
# Only packages targets
python manage.py gen --target packages
# Only auto-discovered extensions
python manage.py gen --target extensions
# Combined with language
python manage.py gen --ts --target adminList Configured Targets
python manage.py gen --list-targetsOutput:
OpenAPI targets:
typescript:
[admin] frontend/apps/admin/app/_lib/api/generated
groups: cfg_*, profiles
[packages] frontend/packages/api/src/generated
groups: cfg_accounts, cfg_totp
extensions (auto-discovered from frontend/extensions):
[ext_support] frontend/extensions/ext-support/src/api/generated
[ext_leads] frontend/extensions/ext-leads/src/api/generatedGroup Filtering
# Specific groups only
python manage.py gen --groups profiles catalog
# Single group
python manage.py gen --groups cfg_accounts
# Specific group in specific target
python manage.py gen --target extensions --groups ext_supportDry Run
# Preview what would be generated without writing files
python manage.py gen --dry-runSafe Writes and --force
Every generator (OpenAPI clients for TypeScript, Python, Go and Swift, the ORM mirror, SDK packages) cleans its output folder and writes it again. It no longer does that in place: a target is generated into a hidden copy next to the folder (.<name>.djcfg-stage-*, same disk) and the folder is replaced only when the target succeeded. If generation fails at any point, the output folder is left exactly as it was. Before anything is generated, the ORM targets are checked: an app in ORMTarget.apps that is not installed stops the run with an error naming it, and nothing is written.
When the output folder is inside a git repository, gen also refuses to replace it while git status shows uncommitted changes there that the generator did not make itself, such as a hand edit or a new file you added. The error lists the files. Commit or move them, or rerun with --force to overwrite them. Changes the generator made itself (output you have not committed yet) and deleted files do not block. Without git, or outside a repository, this check is skipped.
python manage.py gen --force # overwrite uncommitted changes in the output foldersTypeScript Type-Check
A TypeScript client is published only if it type-checks. Before a generated tree replaces its output folder, gen runs tsc --noEmit on it. It uses the frontend’s own TypeScript and tsconfig.json, and the check sees the tree as if it were already in place, so imports of the runtime and of node_modules resolve as they will for the app. A type error in a generated file fails that target: the output folder keeps its previous tree, and gen exits non-zero with the diagnostics. Errors in hand-written files the client imports do not fail generation. Missing TypeScript or Node is an error, not a skip.
To generate without the check for one run, set DJANGO_CFG_GEN_SKIP_TYPECHECK=1. Use it when the check cannot run for a reason outside the tree. For example, a client that imports @djangocfg/api needs that package built first. It is also how to inspect a tree that fails: generate it with the check off, then run the app’s tsc --noEmit.
DJANGO_CFG_GEN_SKIP_TYPECHECK=1 python manage.py gen --tsCommon Workflows
Development
# Quick TypeScript regeneration after API change
python manage.py gen --ts
# Full regeneration
python manage.py gen
# Check config before running
python manage.py gen --list-targets
python manage.py gen --dry-runCI/CD
python manage.py gen --dry-run # validate
python manage.py gen # generateMakefile Integration
api:
python manage.py gen
api-ts:
python manage.py gen --ts
api-list:
python manage.py gen --list-targetsAll Flags
| Flag | Description |
|---|---|
--ts | TypeScript only |
--py | Python only |
--go | Go only |
--swift | Swift only |
--target TYPE | Filter by target type (admin, packages, extensions, parsers, sdk, web) |
--groups GROUP ... | Generate specific groups only |
--dry-run | Preview without writing files |
--force | Replace an output folder even when it holds uncommitted changes the generator did not make |
--list-targets | Show all configured targets and exit |