Installation Guide
Get a production-ready Django project in 30 seconds with the CLI: django-cfg create-project "My Project"
Installation Process Overview
Requirements
Python 3.12+ is required. Django-CFG uses modern Python features and type hints.
Django must be installed separately (peer dependency). Compatible with Django 4.2+ and Django 5.x.
Quick Installation
1. Install Django-CFG
- pip
- Poetry
- pipenv
# Create virtual environment
python3.12 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install Django and Django-CFG
pip install django
pip install django-cfg
# Create project directory
mkdir my-project && cd my-project
# Initialize Poetry
poetry init --no-interaction
# Add dependencies
poetry add django django-cfg
# Activate environment
poetry shell
# Create environment and install
pipenv install django django-cfg
# Activate environment
pipenv shell
Always use a virtual environment to avoid dependency conflicts. Never install Django-CFG globally.
2. Create Project with CLI
# Create complete project structure
django-cfg create-project "My Project"
# Navigate to project
cd my-project
# Run development server
python manage.py runserver
The CLI creates a complete production-ready project with:
- Type-safe configuration with pydantic-settings
- Environment variable configuration (.env files)
- Modern admin interface (Unfold)
- API documentation (DRF Spectacular)
- All migrations and initial data :::
Access your application:
- Main app: http://127.0.0.1:8000/
- Admin panel: http://127.0.0.1:8000/admin/
- API docs: http://127.0.0.1:8000/api/docs/
Alternative Installation Methods
Using different package managers
Using Poetry (Recommended)
# Create project directory
mkdir my-project && cd my-project
# Initialize Poetry
poetry init --no-interaction
# Add dependencies
poetry add django django-cfg
# Create project structure
poetry run django-cfg create-project "My Project"
Using pipenv
# Create environment and install
pipenv install django django-cfg
# Create project
pipenv run django-cfg create-project "My Project"
Using uv (Fast)
# Create environment
uv venv
source .venv/bin/activate
# Install dependencies
uv pip install django django-cfg
# Create project
django-cfg create-project "My Project"
Manual Project Setup
If you prefer manual setup instead of create-project CLI:
1. Install Django
- pip
- Poetry
pip install django
poetry add django
2. Create Django Project
django-admin startproject myproject
cd myproject
3. Install Django-CFG
- pip
- Poetry
pip install django-cfg
poetry add django-cfg
4. Create Environment Module
Create myproject/environment/ directory:
myproject/
├── myproject/
│ ├── __init__.py
│ ├── environment/ # New directory
│ │ ├── __init__.py
│ │ ├── loader.py
│ │ ├── config.dev.yaml
│ │ ├── config.prod.yaml
│ │ └── config.test.yaml
│ ├── config.py # New file
│ └── settings.py
└── manage.py
- __init__.py
- loader.py
- config.dev.yaml
from .loader import env
__all__ = ["env"]
# See Configuration Guide for complete implementation
from pydantic import BaseModel
import yaml
# Load YAML configuration based on environment
# Full example: /getting-started/configuration
secret_key: "dev-secret-key-at-least-fifty-characters-long"
debug: true
app:
name: "My Project"
site_url: "http://localhost:3000"
api_url: "http://localhost:8000"
security_domains:
- "localhost"
- "127.0.0.1"
database:
url: "sqlite:///db.sqlite3"
See Configuration Guide for complete loader.py implementation with Pydantic models.
5. Create Configuration Class
from django_cfg import DjangoConfig, DatabaseConfig
from typing import Dict
from .environment import env
class MyProjectConfig(DjangoConfig):
"""Project configuration loaded from YAML"""
# From environment YAML
secret_key: str = env.secret_key
debug: bool = env.debug
project_name: str = env.app.name
site_url: str = env.app.site_url
api_url: str = env.app.api_url
# Security
security_domains: list[str] = env.security_domains or []
# Database from URL
databases: Dict[str, DatabaseConfig] = {
"default": DatabaseConfig.from_url(url=env.database.url)
}
# Create instance
config = MyProjectConfig()
6. Update settings.py
Replace settings.py content with:
from .config import config
# Import all Django-CFG settings
globals().update(config.get_all_settings())
# Optional: add custom Django settings
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
Always import config.get_all_settings() first, then add custom settings. This ensures proper override behavior.
7. Run Django
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Optional Features
Django-CFG supports optional feature groups (extras) for specific use cases. Install only what you need:
- Full (Recommended)
- AI Agents
- gRPC
- Centrifugo (WebSocket)
- Redis Queue (RQ)
pip install django-cfg[full]
Includes: All optional dependencies (grpc, centrifugo, rq, ai, and more)
Use case: Full-featured production setup with all integrations
pip install django-cfg[ai]
Includes: pydantic-ai
Use case: Build AI-powered workflows with Django integration
pip install django-cfg[grpc]
Includes: grpcio, grpcio-tools, grpcio-reflection, grpcio-health-checking, protobuf
Use case: Build microservices with gRPC communication
pip install django-cfg[centrifugo]
Includes: cent, websockets
Use case: Real-time WebSocket communication and live updates
pip install django-cfg[rq]
Includes: django-rq, rq, rq-scheduler, redis, hiredis
Use case: Background tasks and job queue processing with Redis
You can install multiple extras at once:
pip install django-cfg[grpc,centrifugo,rq]
# or with Poetry
poetry add django-cfg[grpc,centrifugo,rq]
Troubleshooting
Python Version Error
- macOS
- Ubuntu/Debian
- pyenv (Recommended)
- Windows
# Using Homebrew
brew install python@3.12
# Verify installation
python3.12 --version
# Add deadsnakes PPA
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
# Install Python 3.12
sudo apt install python3.12 python3.12-venv
# Verify installation
python3.12 --version
# Install pyenv first (see pyenv docs)
# Install Python 3.12
pyenv install 3.12.0
# Set as global default
pyenv global 3.12.0
# Verify
python --version
# Download from https://www.python.org/downloads/
# or use winget
winget install Python.Python.3.12
# Verify installation
python --version
Virtual Environment Not Activating
- Linux/macOS
- Windows
# Check available Python versions
ls /usr/bin/python*
ls /usr/local/bin/python*
# Try full path
/usr/local/bin/python3.12 -m venv .venv
# Or use virtualenv
pip install virtualenv
virtualenv -p python3.12 .venv
# Allow script execution (run as Administrator)
Set-ExecutionPolicy RemoteSigned
# Create venv
python -m venv .venv
# Activate
.venv\Scripts\activate
Django Not Installed
Django is a peer dependency and is not installed automatically with django-cfg. You must install it separately.
pip install django
Compatible versions:
- Django 4.2+ ✅
- Django 5.0+ ✅
- Django 5.1+ ✅
Dependencies
Django-CFG automatically installs:
Core Dependencies
Type Validation & Configuration:
- pydantic >=2.11.0 - Type validation
- pydantic-settings >=2.0.0 - Environment configuration
- python-dotenv >=1.0.0 - .env file loading
- click >=8.2.0 - CLI interface
Django Integration:
- djangorestframework >=3.16.0
- djangorestframework-simplejwt >=5.5.0
- django-cors-headers >=4.7.0
- django-redis >=6.0.0
- django-unfold >=0.64.0 - Modern admin
Database:
- psycopg >=3.2.0 - PostgreSQL driver
- dj-database-url >=3.0.0 - Database URL parsing
See pyproject.toml for complete dependency list.
Verification
Verify installation:
- Python Shell
- CLI
# In Python shell
import django_cfg
print(django_cfg.__version__) # Should print version
from django_cfg import DjangoConfig
# Should not raise ImportError
django-cfg --version
django-cfg --help
Next Steps
Start Building
- Configuration Guide - Set up YAML configuration with Pydantic models
- First Project - Complete step-by-step tutorial
- Why Django-CFG? - Learn the benefits and features
Explore Features
- Sample Project Guide - Complete production example with all features
- Examples - Real-world code examples and use cases
- Built-in Apps - Production-ready apps (support, AI agents, payments)
- AI Agents - AI-first Django framework capabilities
- API Generation - Auto-generate TypeScript/Python clients
Configuration Deep Dive
- Configuration Models - Complete API reference for DjangoConfig
- Type-Safe Configuration - Pydantic validation benefits
- Environment Detection - Auto-detect dev/staging/production
Migration
- Migration Guide - Migrate existing Django project to Django-CFG
- vs Alternatives - Compare with django-environ, decouple
Troubleshooting
- Troubleshooting - Common installation and configuration issues
- FAQ - Frequently asked questions
TAGS: installation, setup, pip, poetry, django-cfg DEPENDS_ON: [intro] USED_BY: [configuration, first-project]