Skip to main content

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 --help

Quick 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-pip

Check System Information

# Basic information
django-cfg info

# Detailed information with paths
django-cfg info --verbose

Enhanced 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 admin@example.com

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."""
pass

Development 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.py

Command Categories

Project Management

  • create-project - Create new Django projects
  • info - System and installation information

Development Tools

  • runserver - Enhanced development server
  • migrator - Smart database migrations
  • validate-config - Configuration validation

Utilities

  • show-config - Display current configuration
  • show-urls - List all URL patterns
  • superuser - Enhanced superuser creation
  • test-email - Test email configuration
  • test-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 detection

Command Reference

Core Commands

Feature-Specific Commands

Guides & Configuration

Tips & Best Practices

  1. Use Poetry - Django-CFG projects work best with Poetry for dependency management
  2. 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)"
  3. Check Dependencies - Use django-cfg info --verbose to verify your setup
  4. Read Help - Every command has detailed help with --help flag
  5. Chain Commands - Combine multiple commands for complex workflows
  6. 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:

Feature Commands:

Getting Started

Project Setup:

Configuration:

Features & Deployment

Built-in Apps:

Deployment: