CLI Tools Introduction
Django-CFG provides a powerful command-line interface built with Click for project management, development, and deployment tasks.
Overview
The CLI system includes:
- Project Creation - Bootstrap new Django projects with full Django-CFG setup
- Information Display - Check installation status and dependencies
- Enhanced Commands - Improved versions of standard Django management commands
- Development Tools - Utilities for configuration validation and debugging
Installation
The CLI is automatically available after installing Django-CFG:
# Install Django-CFG
pip install django-cfg
# Verify CLI is available
django-cfg --helpQuick Start
Create a New Project
# Create project in current directory
django-cfg create-project "My Awesome Project"
# Create project in specific location
django-cfg create-project "My Project" --path ./projects/
# Skip automatic dependency installation
django-cfg create-project "My Project" --no-deps
# Use pip instead of Poetry
django-cfg create-project "My Project" --use-pipCheck System Information
# Basic information
django-cfg info
# Detailed information with paths
django-cfg info --verboseEnhanced Management Commands
Django-CFG projects include enhanced versions of standard Django commands:
# In your Django-CFG project directory
cd my_project/
# Enhanced runserver with better output
poetry run cli runserver --port 8080 --host 0.0.0.0
# Smart migrator with automatic database detection
poetry run cli migrator --auto
# Configuration validation
poetry run cli validate-config --show-details
# Show project URLs in table format
poetry run cli show-urls --format table
# Enhanced superuser creation
poetry run cli superuser --email [email protected]Features
Rich Output
The CLI uses Rich library for beautiful, colored output:
- ✅ Success indicators with green checkmarks
- ⚠️ Warnings with yellow alerts
- ❌ Errors with red crosses
- 📦 Progress indicators for long operations
- 🎨 Syntax highlighting for code and configuration
Smart Defaults
- Auto-detection of Poetry vs pip environments
- Intelligent fallbacks when commands fail
- Environment-aware configuration loading
- Dependency checking with helpful error messages
Type Safety
All CLI commands use Click with full type hints:
@click.command()
@click.argument("project_name", type=str)
@click.option("--port", type=int, default=8000)
@click.option("--debug", is_flag=True)
def runserver(project_name: str, port: int, debug: bool):
"""Enhanced runserver command."""
passDevelopment Mode
When developing Django-CFG itself, additional commands are available:
# Create template archive for project creation
python scripts/template_manager.py create
# Validate all configurations
python scripts/validate_configs.py
# Run comprehensive tests
python scripts/test_all.pyCommand Categories
Project Management
create-project- Create new Django projectsinfo- System and installation information
Development Tools
runserver- Enhanced development servermigrator- Smart database migrationsvalidate-config- Configuration validation
Utilities
show-config- Display current configurationshow-urls- List all URL patternssuperuser- Enhanced superuser creationtest-email- Test email configurationtest-telegram- Test Telegram integration
Integration with Django
Django-CFG CLI commands seamlessly integrate with standard Django management:
# Standard Django commands still work
python manage.py runserver
python manage.py migrate
# Enhanced CLI commands provide better UX
poetry run cli runserver # Better output, more options
poetry run cli migrator # Smart database detectionCommand Reference
Core Commands
- Core Commands - Essential project management commands (info, create-project, validate-config)
- Development Commands - Development server, migrations, debugging tools
- Custom Commands - Create your own management commands
Feature-Specific Commands
- AI Agent Commands - Manage AI workflows and agent execution
- Knowledge Base Commands - Document ingestion and semantic search
- Background Task Commands - Manage Django-RQ workers and tasks
- Payment Commands - Test payment integrations and webhooks
- Maintenance Commands - Enable/disable maintenance mode
Guides & Configuration
- Configuration Guide - Configure CLI behavior and defaults
- Production Best Practices - CLI usage in production
- Troubleshooting - Common CLI issues
Tips & Best Practices
- Use Poetry - Django-CFG projects work best with Poetry for dependency management
- Enable Auto-completion - Most terminals support Click auto-completion:
# Bash eval "$(_DJANGO_CFG_COMPLETE=bash_source django-cfg)" # Zsh eval "$(_DJANGO_CFG_COMPLETE=zsh_source django-cfg)" - Check Dependencies - Use
django-cfg info --verboseto verify your setup - Read Help - Every command has detailed help with
--helpflag - Chain Commands - Combine multiple commands for complex workflows
- Use Environment Variables - Configure defaults via
DJANGO_CFG_*environment variables
The CLI is designed to make Django development faster, safer, and more enjoyable! 🚀
See Also
CLI Commands
Core Commands:
- Core Commands - Essential project management commands
- Development Commands - Development server and debugging tools
- Custom Commands - Create your own management commands
- Quick Reference - Command cheat sheet
Feature Commands:
- AI Agent Commands - Manage AI workflows and agents
- Knowledge Base Commands - Document ingestion and search
- Background Task Commands - Manage Django-RQ workers
- Payment Commands - Test payment integrations
- Maintenance Commands - Site maintenance control
Getting Started
Project Setup:
- Installation - Install Django-CFG
- First Project - Complete tutorial
- Configuration Guide - Configure your project
- Why Django-CFG - Benefits and features
Configuration:
- Configuration Models - All configuration options
- Type-Safe Configuration - Pydantic patterns
- Environment Detection - Multi-environment setup
- Environment Variables - Secrets management
Features & Deployment
Built-in Apps:
- Built-in Apps Overview - All available apps
- User Management - Accounts and support
- AI Agents - AI workflow automation
- Operations Apps - Maintenance and tasks
Deployment:
- Docker Deployment - Containerized deployment
- Production Config - Production best practices
- Environment Setup - Environment configuration
- Troubleshooting - Common CLI issues