Core Management Commands
Essential commands for Django-CFG project setup, configuration management, and validation.
Project Setup
django-cfg create-project
Creates a new Django project by downloading the latest template from GitHub.
django-cfg create-project PROJECT_NAME [OPTIONS]| Argument/Option | Type | Default | Description |
|---|---|---|---|
PROJECT_NAME | str | required | Name for the project directory (letters, numbers, underscores, hyphens) |
--path, -p | PATH | current dir | Parent directory where to create the project |
--force, -f | flag | False | Overwrite existing directory if it exists |
Examples:
# Basic project creation
django-cfg create-project my_awesome_app
# Create in specific directory
django-cfg create-project my_saas --path /projects
# Force overwrite existing directory
django-cfg create-project my_app --forceWhat it creates: the CLI extracts the public repository’s solution directory into the target directory. Root agent instructions and workflow are not extracted by this command. Use DevOps Quick Start for the complete canonical Docker environment.
Features included:
- ✅ Type-safe configuration with Pydantic v2
- ✅ Django admin with the django-cfg theme and navigation
- ✅ API documentation with Spectacular
- ✅ JWT authentication system
- ✅ Multi-database support
- ✅ Background task processing (django-rq)
- Docker runtime source (see the full Git-root instructions)
django-cfg info
Shows Django-CFG installation and system information.
django-cfg info [OPTIONS]| Option | Type | Description |
|---|---|---|
--verbose, -v | flag | Show detailed information including paths |
Examples:
# Basic information
django-cfg info
# Detailed information with paths
django-cfg info --verboseOutput includes:
- Django-CFG version and Python version
- 📋 Project template availability and status
- Core dependencies (Django, Pydantic, Click)
- 🌐 Service integrations (OpenAI)
- Admin & UI packages (Constance)
- 📊 API & documentation tools (DRF, Spectacular)
- Background processing (Django-RQ, Redis)
- The configured sites: per site its key, name,
site_url, API URL, web origins, sender,Reply-Toand locale. A value taken from the deployment is marked(inherited)(api_urlwhen the site sets none,from_emailfromemail.default_from). Printed only whenDJANGO_SETTINGS_MODULEloads; outside a project the section is skipped.
Configuration Management
show_config
Displays current Django-CFG configuration.
python manage.py show_config [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--format | table|json | table | Output format |
--include-secrets | flag | False | Include sensitive values (use with caution) |
The table has a Sites section, with (inherited) next to values a site took from the deployment. The JSON has a sites array (key, name, site_url, api_url, origins, from_email, from_name, support_email, logo_url, locale) and, per site, inherited: the names taken from the deployment. See Sites.
Examples:
# Show all configuration
python manage.py show_config
# JSON format for automation
python manage.py show_config --format json
# Include sensitive values (be careful!)
python manage.py show_config --include-secretscheck_settings
Comprehensive validation and debugging for Django-CFG configuration.
python manage.py check_settings [OPTIONS]| Option | Type | Description |
|---|---|---|
--email-test | flag | Test email configuration |
--verbose | flag | Verbose output with detailed diagnostics |
Examples:
# Check all settings
python manage.py check_settings
# Test email configuration
python manage.py check_settings --email-test
# Verbose output with detailed diagnostics
python manage.py check_settings --verboseChecks:
- Configuration validity
- Database connections
- Email settings
- Service integrations
- File permissions
- Environment variables
check_editable
Diagnoses the dev gotcha where an editable (pip install -e) django-cfg
checkout gets silently shadowed by a PyPI copy — e.g. a plain uv sync
reinstalling the published wheel over your editable link — or by anything
else shadowing the package (a stray PYTHONPATH entry, a leftover copy, a
second virtualenv). Read-only; it never mutates anything.
This is a framework-contributor / local-checkout tool. It only fires for
machines developing django-cfg itself (keyed off a ~/djangocfg checkout or
the DJANGO_CFG_EDITABLE_EXPECTED env var). A typical consumer app running
the published PyPI wheel will just see “no editable install expected on this
machine” and exit clean.
python manage.py check_editable [OPTIONS]| Option | Type | Description |
|---|---|---|
--strict | flag | Exit with code 1 on mismatch (default: always exits 0) |
Output fields:
- Loaded from — the directory
django_cfgactually imported from (django_cfg.__file__’s parent) - In site-packages — whether that path lives in an installed-packages tree
- Editable source — the resolved
~/djangocfgcheckout path, or “not found” - Editable env — whether
DJANGO_CFG_EDITABLE_EXPECTEDis set - Editable expected — whether either signal above means an editable install was intended
Examples:
# Check where django-cfg is actually loaded from
python manage.py check_editable
# Fail the command (exit 1) if a mismatch is found — useful in a pre-flight script
python manage.py check_editable --strictOn a mismatch, the message names what was actually found instead of always blaming PyPI:
- Loaded from site-packages →
❌ django-cfg loaded from PyPI copy (site-packages)... Fix: make install-local - Loaded from somewhere else entirely →
❌ django-cfg loaded from outside your editable source... check PYTHONPATH, a stray django_cfg/ copy, or a second virtualenv.
The same message branching also drives the yellow startup-banner warning you
get in dev when django-cfg boots from the wrong copy — check_editable just
lets you check it on demand.
API Endpoints Testing
check_endpoints
Check health and availability of all registered API endpoints.
python manage.py check_endpoints [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--include-unnamed | flag | False | Include unnamed URL patterns in the check |
--timeout | INTEGER | 5 | Request timeout in seconds |
--json | flag | False | Output results as JSON |
--url | TEXT | - | Check specific endpoint by URL name |
--no-auth | flag | False | Disable automatic JWT authentication retry |
Examples:
# Check all endpoints (with auto-auth for protected endpoints)
python manage.py check_endpoints
# Include unnamed URL patterns
python manage.py check_endpoints --include-unnamed
# Custom timeout (10 seconds)
python manage.py check_endpoints --timeout 10
# Disable auto-auth (show 401/403 as-is)
python manage.py check_endpoints --no-auth
# JSON output for automation/CI
python manage.py check_endpoints --json
# Check specific endpoint by name
python manage.py check_endpoints --url endpoints_statusOutput:
❌ Overall Status: UNHEALTHY
📊 Summary:
Total endpoints: 399
✅ Healthy: 0
⚠️ Warnings: 0
❌ Unhealthy: 69
❌ Errors: 90
⏭️ Skipped: 240
🔗 Endpoints:
✅ endpoints_status
URL: /cfg/api/endpoints/
Status: healthy
Response time: 0.123s
✅ api_users_list
URL: /api/users/
Status: healthy
Response time: 0.245s
🔐 Required JWT authentication
❌ api_payments_list
URL: /api/payments/
Status: unhealthy
Error: Database connection failedJSON Output:
{
"status": "unhealthy",
"timestamp": "2025-10-05T18:00:20.111738+00:00",
"total_endpoints": 399,
"healthy": 0,
"unhealthy": 69,
"warnings": 0,
"errors": 90,
"skipped": 240,
"endpoints": [
{
"url": "/cfg/api/endpoints/",
"url_name": "endpoints_status",
"namespace": "",
"group": "cfg/api/endpoints",
"view": "EndpointsStatusView",
"status": "healthy",
"status_code": 200,
"response_time_ms": 0.23,
"is_healthy": true,
"last_checked": "2025-10-05T18:00:20.111738+00:00",
"required_auth": false
},
{
"url": "/api/users/",
"url_name": "api_users_list",
"namespace": "",
"group": "api/users",
"view": "UserViewSet",
"status": "healthy",
"status_code": 200,
"response_time_ms": 0.45,
"is_healthy": true,
"last_checked": "2025-10-05T18:00:20.211738+00:00",
"required_auth": true
}
]
}What it checks:
- ✅ All registered URL patterns
- ✅ HTTP status codes (200, 401, 403, etc.)
- ✅ Response times in milliseconds
- ✅ Endpoint availability
- ✅ Error detection and reporting
- ✅ Grouping by URL namespace
Excluded endpoints:
- ❌ Admin endpoints (
/admin/) - ❌ Static/media files (
/static/,/media/) - ❌ Health check endpoints (
/healthz/ready) - ❌ Schema documentation (
/schema/) - ❌ Django debug toolbar (
/__debug__/,/__reload__/)
Status Categories:
| Status | Description | HTTP Codes |
|---|---|---|
| Healthy | Endpoint working correctly | 200-299, 301-308, 401, 403, 405 |
| Warning | Might be OK (no data) | 404 |
| Unhealthy | Endpoint has issues | 400, 500+ |
| Error | Exception occurred | Connection errors, timeouts |
| Skipped | Requires parameters | URLs with <pk>, <id> |
Use Cases:
Development:
# Quick check during development
python manage.py check_endpointsCI/CD Pipeline:
# Automated testing in GitHub Actions
python manage.py check_endpoints --json > endpoints-report.jsonProduction Monitoring:
# Health check with custom timeout
python manage.py check_endpoints --timeout 10Debugging:
# Check specific problematic endpoint
python manage.py check_endpoints --url api_users_listFeatures:
- ✅ Auto-discovers all registered endpoints
- ✅ Smart JWT Auto-Authentication - Automatically retries protected endpoints with JWT token
- ✅ Creates test user
endpoint_test_useronce and reuses token - ✅ Respects Django Test Client
- ✅ No ALLOWED_HOSTS issues (uses localhost)
- ✅ Excludes schema documentation (prevents rate limiting issues)
- ✅ Excludes recursive endpoints (health checks)
- ✅ Colored console output with emojis
- ✅ JSON export for automation
- ✅ Response time measurement
- ✅ Indicates which endpoints required authentication (🔐)
Database Operations
migrate_all
Migrate all databases based on django-cfg configuration.
python manage.py migrate_all [OPTIONS]| Option | Type | Description |
|---|---|---|
--check | flag | Forensic check only: no DDL, no record changes; exit 1 on any drift |
--repair | flag | Auto-repair detected drift (fake-apply / fake-rewind) |
--skip-makemigrations | flag | Skip makemigrations step |
--non-interactive | flag | Refuse every interactive prompt (CI mode) |
Examples:
# Migrate all databases
python manage.py migrate_all
# Report drift without changing anything
python manage.py migrate_all --check
# Skip makemigrations
python manage.py migrate_all --skip-makemigrationsFeatures:
- Auto-detects all databases from django-cfg configuration
- Creates migrations for all apps
- Migrates each database based on routing configuration
- Migrates constance separately
- Handles app-specific routing
migrator
Interactive database migration tool with automatic database detection and routing support.
python manage.py migrator [OPTIONS]| Option | Type | Description |
|---|---|---|
--auto | flag | Automatic migration mode (no prompts, migrates all databases) |
--database | TEXT | Target specific database only |
--app | TEXT | Target specific app only |
Examples:
# Interactive mode (default) - shows menu
python manage.py migrator
# Auto-migrate all databases (no prompts)
python manage.py migrator --auto
# Migrate specific database
python manage.py migrator --database blog_db
# Migrate specific app across all databases
python manage.py migrator --app blog
# Migrate specific app on specific database
python manage.py migrator --database blog_db --app blogInteractive Mode:
When run without --auto, shows an interactive menu:
🗄️ Django Database Migrator
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Current Configuration:
Databases: default, blog_db, shop_db
Apps: accounts, blog, shop, profiles
What would you like to do?
> Migrate all databases (recommended)
Migrate specific database
Show database status
View configuration info
ExitAuto Mode (--auto):
Runs automatic migration without prompts:
- Creates migrations - Runs
makemigrationsfor all apps - Migrates default database - Migrates main database first
- Migrates routed databases - Migrates blog_db, shop_db based on routing rules
- Migrates constance - Always migrates constance app (required by django-cfg)
Example Output:
$ python manage.py migrator --auto
🚀 Running automatic migration...
📦 Creating migrations for all apps...
✅ Migrations created successfully
🔄 Migrating database: default
📦 Migrating all apps...
✅ Migrations completed for default
🔄 Migrating database: blog_db
📦 Migrating app: blog
✅ Migrations completed for blog_db
🔄 Migrating database: shop_db
📦 Migrating app: shop
✅ Migrations completed for shop_db
✅ Constance migrated successfullyHow Routing Works:
The migrator respects DATABASE_ROUTING_RULES from settings:
DATABASE_ROUTING_RULES = {
'blog': 'blog_db',
'shop': 'shop_db',
}- Apps listed in routing rules → migrate on their target database only
- Apps NOT listed → migrate on default database
- Constance app → always migrates on default database
Comparison with migrate_all:
| Feature | migrator --auto | migrate_all |
|---|---|---|
| Interactive menu | ✅ Yes (without —auto) | ❌ No |
| Auto makemigrations | ✅ Yes | ✅ Yes (unless —skip-makemigrations) |
| Respects routing rules | ✅ Yes | ✅ Yes |
| Specific database | ✅ —database flag | ❌ Migrates all |
| Specific app | ✅ —app flag | ❌ Migrates all apps |
| Constance handling | ✅ Automatic | ✅ Automatic |
| Best for | Development, targeted migrations | Production, CI/CD |
Use Cases:
Development:
# Quick migration during development
python manage.py migrator --autoTesting specific database:
# Test blog database migrations only
python manage.py migrator --database blog_dbTroubleshooting:
# Interactive mode to explore database status
python manage.py migrator
# Select "Show database status" from menuCI/CD Pipeline:
# Production deployment - use migrate_all
python manage.py migrate_allFeatures:
- ✅ Automatic database discovery from settings
- ✅ Respects DATABASE_ROUTING_RULES
- ✅ Interactive menu with questionary
- ✅ Progress indicators with emojis
- ✅ Database status checking
- ✅ Configuration info display
- ✅ Constance app auto-migration
Development Server
runserver
Enhanced development server with better output and options.
poetry run python manage.py runserver [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--port | INTEGER | 8000 | Port number |
--host | TEXT | 127.0.0.1 | Host address |
--debug | flag | False | Enable debug mode |
--no-reload | flag | False | Disable auto-reload |
Examples:
# Basic server
poetry run python manage.py runserver
# Custom port and host
poetry run python manage.py runserver --port 3000 --host 0.0.0.0
# Production-like settings
poetry run python manage.py runserver --no-reload --port 8080Features:
- Rich colored output
- 📊 Better error formatting
- Faster startup time
- Smart configuration detection
User Management
superuser
Enhanced superuser creation with better UX.
poetry run python manage.py superuser [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--email | TEXT | - | Email address for superuser |
--username | TEXT | - | Username |
--password | TEXT | - | Password |
--first-name, --last-name | TEXT | - | Name fields |
--interactive | flag | False | Prompt for everything (also the behaviour when no value is given) |
Examples:
# Interactive superuser creation
poetry run python manage.py superuser
# Pre-fill email
poetry run python manage.py superuser --email [email protected]
# Non-interactive: give the values on the command line
poetry run python manage.py superuser --username admin --email [email protected] --password '<password>'create_token
Create API tokens for authentication.
python manage.py create_token [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--user | TEXT | - | Username to create the token for |
--type | api|auth|secret | - | Type of token |
--length | INTEGER | 32 | Token length |
--expires | INTEGER | - | Expiration in days |
Without --user and --type the command asks for them interactively.
Examples:
# Create an API token for a user
python manage.py create_token --user admin --type api
# Create a token that expires in 30 days
python manage.py create_token --user admin --type api --expires 30oauth_check
Diagnose Google and GitHub sign-in and print what to register at each provider.
python manage.py oauth_check
python manage.py oauth_check --probe| Option | Description |
|---|---|
--probe | Ask each enabled provider whether the client id and secret are accepted (one token-endpoint call with a dummy code; invalid_grant = accepted, invalid_client = wrong) |
Per provider it prints on or off (and which variables turn it on), the redirect URIs for every site origin, the console link, then the setup findings (django_cfg.W030 to W035). Exit code 1 on any finding or failed probe. See OAuth configuration and Google Cloud setup.
email_key_report
List emails that map to more than one live user (accounts created before the canonical email_key existed). Reports only, never merges. Exit code 1 when duplicates exist.
python manage.py email_key_reportURL Management
show_urls
Lists all URL patterns in the project.
poetry run python manage.py show_urls [OPTIONS]| Option | Type | Default | Description |
|---|---|---|---|
--format | list|tree|table | tree | Output format |
--filter | TEXT | - | Filter URLs by pattern (regex) |
--namespace | TEXT | - | Only URLs of one namespace |
--include-unnamed | flag | False | Include URLs without a name |
--show-methods | flag | False | Show HTTP methods |
--show-views | flag | False | Show view functions and classes |
--plain | flag | False | No colors |
Examples:
# Show all URLs as a tree
poetry run python manage.py show_urls
# Table with methods
poetry run python manage.py show_urls --format table --show-methods
# Filter API URLs only
poetry run python manage.py show_urls --filter "api/"
# One namespace
poetry run python manage.py show_urls --namespace cfg_accountslist_urls
List all URL patterns in the project.
python manage.py list_urls [OPTIONS]| Option | Type | Description |
|---|---|---|
--filter | TEXT | Only URLs containing this string |
--api | flag | Only API URLs |
--webhook | flag | Only webhook-related URLs |
Examples:
# List all URLs
python manage.py list_urls
# Filter by text
python manage.py list_urls --filter users
# API URLs only
python manage.py list_urls --api
# Webhook URLs only
python manage.py list_urls --webhookUtility Commands
clear_constance
Clear Constance dynamic settings cache.
python manage.py clear_constance [OPTIONS]| Option | Type | Description |
|---|---|---|
--cache-only | flag | Clear only the cache, not the database records |
--db-only | flag | Clear only the database records, not the cache |
--confirm | flag | Skip the confirmation prompt |
--dry-run | flag | Show what would be cleared without clearing it |
Examples:
# Clear all constance cache
python manage.py clear_constance
# Database records only, no prompt
python manage.py clear_constance --db-only --confirm
# Dry run to see what would be cleared
python manage.py clear_constance --dry-runTips
- Use
check_settings --verbosebefore deployment - Use
migrate_all --checkto preview migrations - Use
create_token --expires 90for limited lifetime tokens
Workflow Examples
# Pre-deployment checklist
python manage.py check_settings --verbose && \
python manage.py check_settings --verbose && \
python manage.py migrate_all --check