Skip to main content

Modern Django framework with type-safe Pydantic v2 configuration, Next.js admin integration, real-time WebSockets, and 8 enterprise apps. Replace settings.py with validated models, 90% less code. Production-ready with AI agents, auto-generated TypeScript clients, and zero-config features.

Project description

Django-CFG: Type-Safe Django Configuration Framework

Python 3.12+ Django 5.2+ PyPI License: MIT Downloads GitHub Stars

Django-CFG Framework

๐Ÿš€ The Modern Django Framework for Enterprise Applications

Type-safe configuration โ€ข AI-Native Docs โ€ข Next.js Admin โ€ข gRPC Streaming โ€ข Real-time WebSockets โ€ข AI Agents โ€ข 8 Enterprise Apps

๐ŸŽฏ Live Demo โ€ข ๐Ÿ“š Documentation โ€ข ๐Ÿค– MCP Server โ€ข ๐Ÿ™ GitHub


๐ŸŽฏ What is Django-CFG?

Django-CFG is a next-generation Django framework that replaces traditional settings.py with type-safe Pydantic v2 models. It eliminates runtime configuration errors, provides complete IDE autocomplete, and includes production-ready enterprise features out of the box.

Why Django-CFG?

Traditional Django problems:

  • โŒ Runtime errors - configuration bugs discovered in production
  • โŒ No IDE support - zero autocomplete, manual documentation lookup
  • โŒ 200+ lines of unmaintainable settings.py
  • โŒ Weeks of setup - for user auth, admin UI, payments, real-time features

Django-CFG solution:

  • โœ… Startup validation - catch all config errors before deployment
  • โœ… Full IDE autocomplete - IntelliSense for every setting
  • โœ… 30 lines of code - 90% boilerplate reduction
  • โœ… 30 seconds to production - everything included and ready

๐Ÿ“š Read the full comparison โ†’


๐Ÿš€ Quick Start

Requirements

  • Python 3.12+ (required)
  • pip or poetry

๐Ÿš€ Quick Install

Interactive Installer (Recommended)

Visit our interactive installer page that automatically detects your operating system:

โ†’ https://djangocfg.com/installer

The installer automatically:

  • Detects your OS and architecture
  • Downloads the correct Go binary installer
  • Runs system checks (Python, Docker, Node.js, etc.)
  • Installs missing dependencies
  • Creates a complete project structure
  • Configures environment files

One-Line Commands

Linux / macOS

curl -L https://djangocfg.com/install.sh | sh

Windows (PowerShell)

powershell -c "iwr https://djangocfg.com/install.ps1 | iex"

Note: If you get a PowerShell execution policy error, run PowerShell as Administrator and execute:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

๐Ÿ“ฆ Manual Installation

# Create virtual environment with Python 3.12
python3.12 -m venv .venv && source .venv/bin/activate

# Install django-cfg and create project
pip3 install 'django-cfg[full]'
django-cfg create-project my_app

# Start the server
cd my_app/projects/django
poetry install
poetry run python manage.py runserver

What you get instantly:

  • ๐ŸŽจ Modern Admin UI โ†’ http://127.0.0.1:8000/admin/
  • โšก Next.js Dashboard โ†’ Modern React admin interface
  • ๐Ÿ“ก Real-time WebSockets โ†’ Live updates with Centrifugo
  • ๐Ÿณ Docker Ready โ†’ Production deployment configs
  • ๐Ÿ–ฅ๏ธ Electron App โ†’ Desktop app template

Project structure:

my_app/
โ”œโ”€โ”€ docker/              # Docker deployment
โ””โ”€โ”€ projects/
    โ”œโ”€โ”€ django/          # Django backend
    โ”œโ”€โ”€ frontend/        # Next.js frontend
    โ””โ”€โ”€ electron/        # Desktop app
Django-CFG Startup Screen

Django-CFG startup with type-safe configuration validation

๐Ÿ“š Installation Guide โ†’

Optional Features (Extras)

Install additional features based on your needs:

# Full installation (recommended for production)
pip3 install 'django-cfg[full]'

# Individual extras
pip3 install 'django-cfg[grpc]'        # gRPC microservices
pip3 install 'django-cfg[centrifugo]'  # Real-time WebSockets
pip3 install 'django-cfg[rq]'          # Background tasks with Redis Queue
pip3 install 'django-cfg[ai]'          # AI agents with Pydantic AI

# Combine multiple extras
pip3 install 'django-cfg[grpc,centrifugo,rq]'

Note: Quotes around extras are required for zsh compatibility.

Available extras:

  • ๐Ÿ”„ [full] - All features (grpc + centrifugo + rq + ai)
  • ๐ŸŒ [grpc] - gRPC server support (grpcio, grpcio-tools, protobuf)
  • ๐Ÿ“ก [centrifugo] - Real-time WebSocket integration (cent, websockets)
  • ๐Ÿ“‹ [rq] - Redis Queue for background tasks (django-rq, rq-scheduler)
  • ๐Ÿค– [ai] - AI agents framework (pydantic-ai)

Try Live Demo

See Django-CFG in action:

โ†’ https://djangocfg.com/demo

Demo credentials:

  • Admin: admin@example.com / admin123

Explore: Modern admin โ€ข Next.js dashboard โ€ข AI agents โ€ข Real-time updates โ€ข Support system


๐Ÿ’ก Core Features

๐Ÿ”’ Type-Safe Configuration with Pydantic v2

Replace error-prone settings.py with validated Pydantic models.

Before: Django settings.py

# settings.py - Runtime errors, no validation
import os

DEBUG = os.getenv('DEBUG', 'False') == 'True'  # โŒ String comparison bug
DATABASE_PORT = os.getenv('DB_PORT', '5432')   # โŒ Still a string!

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('DB_NAME'),  # โŒ No validation until connection
        'PORT': DATABASE_PORT,          # โŒ Type mismatch in production
    }
}
# ... 200+ more lines

After: Django-CFG

# config.py - Type-safe, validated at startup
from django_cfg import DjangoConfig, DatabaseConfig

class MyConfig(DjangoConfig):
    """Production-ready type-safe configuration"""

    project_name: str = "My App"
    debug: bool = False  # โœ… Pydantic validates boolean

    # Type-safe database with startup validation
    databases: dict[str, DatabaseConfig] = {
        "default": DatabaseConfig(
            name="${DB_NAME}",  # โœ… Validated at startup
            port=5432,          # โœ… Type-checked integer
        )
    }

Benefits:

  • โœ… Pydantic v2 validation - catch errors before deployment
  • โœ… Full IDE autocomplete - IntelliSense everywhere
  • โœ… 90% less code - 200+ lines โ†’ 30 lines
  • โœ… Type hints - mypy and pyright compatible

๐Ÿ“š Type-safe configuration guide โ†’


โš›๏ธ Next.js Admin Integration

Build modern admin interfaces with React - the only Django framework with built-in Next.js integration.

from django_cfg import DjangoConfig, NextJsAdminConfig

class MyConfig(DjangoConfig):
    # One line for complete Next.js admin!
    nextjs_admin: NextJsAdminConfig = NextJsAdminConfig(
        project_path="../admin",
    )

What you get:

  • ๐ŸŒ Three-in-One Architecture - Public site + User dashboard + Admin panel in ONE Next.js project
  • โš™๏ธ Dual Admin Strategy - Django Unfold (90% quick CRUD) + Next.js (10% complex features)
  • โœจ Zero Configuration - Auto JWT auth, theme sync, TypeScript generation
  • ๐Ÿ“ฆ 60% Smaller - ZIP deployment (~7MB vs ~20MB)
  • โšก Auto-Detection - Dev mode automatically detected on ports 3000/3001

No migration needed - start with built-in admin, add Next.js when you need complex features!

๐Ÿ“š Next.js Admin Documentation โ†’


๐Ÿ“ก Real-Time WebSockets with Centrifugo

Production-ready WebSocket integration - live updates, notifications, and real-time collaboration.

from django_cfg import DjangoConfig, CentrifugoConfig

class MyConfig(DjangoConfig):
    # Enable real-time features
    centrifugo: CentrifugoConfig = CentrifugoConfig(
        enabled=True,
        api_url="http://localhost:8001/api",
    )

Built-in features:

  • โšก Live Updates - Real-time data synchronization
  • ๐Ÿ”” Notifications - Push notifications to connected clients
  • ๐Ÿ‘ฅ Presence - Track online users
  • ๐Ÿ’ฌ Chat - Real-time messaging out of the box
  • ๐Ÿ”’ JWT Auth - Secure WebSocket connections

๐Ÿ“š Centrifugo Integration Guide โ†’


๐ŸŒ gRPC Microservices & Streaming

Production-ready gRPC integration - bidirectional streaming, WebSocket bridge, and type-safe Protobuf.

from django_cfg.apps.integrations.grpc.services.centrifugo import (
    CentrifugoBridgeMixin,
    CentrifugoChannels,
    ChannelConfig,
)

# Define type-safe channel mappings
class BotChannels(CentrifugoChannels):
    heartbeat: ChannelConfig = ChannelConfig(
        template='bot#{bot_id}#heartbeat',
        rate_limit=5.0,  # Max once per 5 seconds
    )
    status: ChannelConfig = ChannelConfig(
        template='bot#{bot_id}#status',
        critical=True,  # Bypass rate limiting
    )

# gRPC service with automatic WebSocket publishing
class BotStreamingService(
    pb2_grpc.BotStreamingServiceServicer,
    CentrifugoBridgeMixin  # โ† One-line WebSocket integration
):
    centrifugo_channels = BotChannels()
    
    async def ConnectBot(self, request_iterator, context):
        async for message in request_iterator:
            # Your business logic
            await process_message(message)
            
            # Auto-publish to WebSocket (1 line!)
            await self._notify_centrifugo(message, bot_id=bot_id)

Built-in features:

  • ๐Ÿ”„ Bidirectional Streaming - Full-duplex gRPC communication
  • ๐ŸŒ‰ Centrifugo Bridge - Auto-publish gRPC events to WebSocket
  • ๐Ÿ›ก๏ธ Circuit Breaker - Graceful degradation if Centrifugo unavailable
  • ๐Ÿ” Auto Retry - Exponential backoff for critical events
  • ๐Ÿ“ฆ Dead Letter Queue - Never lose important messages
  • โšก Rate Limiting - Per-channel throttling with critical bypass
  • ๐ŸŽฏ Type-Safe Config - Pydantic v2 validation for channels

Architecture:

Trading Bot โ”€โ”€gRPCโ”€โ”€> Django gRPC Service โ”€โ”€WebSocketโ”€โ”€> Browser
                            โ†“
                      [Business Logic]
                      [Database Save]
                      [Centrifugo Publish]

Why this approach?

  • โœ… Django controls all business logic and validation
  • โœ… Single source of truth for data transformations
  • โœ… Graceful degradation - gRPC works even if WebSocket fails
  • โœ… Production-ready resilience patterns built-in

๐Ÿ“š gRPC Integration Guide โ†’


๐Ÿค– AI-Native Documentation

First Django framework with MCP server - Your AI coding assistant can access DjangoCFG docs instantly.

{
  "mcpServers": {
    "djangocfg-docs": {
      "url": "https://mcp.djangocfg.com/mcp"
    }
  }
}

Access documentation from anywhere:

# CLI search (fast, no Django required)
django-cfg search "database configuration"
django-cfg search "redis cache" --limit 3

# Python API
from django_cfg.modules.django_ai import search, get_docs
results = search("How to configure Redis cache?")

# REST API
curl 'https://mcp.djangocfg.com/api/search?q=database&limit=5'

Supported AI assistants:

  • ๐Ÿค– Claude Desktop - Add MCP server to config
  • ๐Ÿ–ฅ๏ธ Cursor IDE - Native MCP support
  • ๐Ÿ’ฌ ChatGPT - Via API integration
  • ๐Ÿ”ง Any MCP Client - Universal protocol

๐Ÿ“š AI Documentation Guide โ†’


๐Ÿค– AI Agents Framework

Built-in AI agent framework - LLM workflow automation with Django ORM integration.

from django_cfg import DjangoConfig

class MyConfig(DjangoConfig):
    # AI features (optional)
    openai_api_key: str = "${OPENAI_API_KEY}"
    anthropic_api_key: str = "${ANTHROPIC_API_KEY}"

    enable_agents: bool = True      # AI workflow automation
    enable_knowbase: bool = True    # Vector DB + RAG

Features:

  • ๐Ÿค– AI Agents Framework - Type-safe LLM integration
  • ๐Ÿ“š Vector Database - ChromaDB for semantic search
  • ๐Ÿ” RAG - Retrieval-augmented generation
  • ๐ŸŽฏ Pydantic AI - Validated AI input/output
  • ๐ŸŒ Multi-LLM - OpenAI, Anthropic, Claude support

๐Ÿ“š AI Agents Guide โ†’


๐Ÿ“ฆ 8 Enterprise Apps Included

Ship features in days, not months - production-ready apps out of the box:

App Description Time Saved
๐Ÿ‘ค Accounts User management + OTP + SMS auth 3-4 weeks
๐ŸŽซ Support Ticketing system + SLA tracking 2-3 weeks
๐Ÿ“ง Newsletter Email campaigns + analytics 2-3 weeks
๐Ÿ“Š Leads CRM + sales pipeline 2-3 weeks
๐Ÿค– AI Agents Workflow automation 3-4 weeks
๐Ÿ“š KnowBase AI knowledge base + RAG 2-3 weeks
๐Ÿ’ณ Payments Multi-provider payments 2-3 weeks
๐Ÿ”ง Maintenance Multi-site management 1-2 weeks

Total time saved: 18+ months of development

class MyConfig(DjangoConfig):
    # Enable apps as needed (one line each!)
    enable_accounts: bool = True
    enable_support: bool = True
    enable_newsletter: bool = True
    enable_leads: bool = True
    enable_agents: bool = True
    enable_knowbase: bool = True
    enable_payments: bool = True
    enable_maintenance: bool = True

๐Ÿ“š Built-in Apps Overview โ†’


๐ŸŽจ Modern API UI with Tailwind 4

Beautiful browsable API - 88% smaller bundle, modern design.

  • โœ… Glass morphism design
  • โœ… Light/Dark/Auto themes
  • โœ… Command palette (โŒ˜K)
  • โœ… 88% smaller (278KB โ†’ 33KB)
  • โœ… Auto-generated TypeScript clients

๐Ÿ“š API Generation Guide โ†’


๐Ÿ”„ Smart Multi-Database Routing

Zero-config database routing with automatic sharding:

from django_cfg import DjangoConfig, DatabaseConfig

class MyConfig(DjangoConfig):
    databases: dict[str, DatabaseConfig] = {
        "default": DatabaseConfig(
            name="${DB_NAME}",
        ),
        "analytics": DatabaseConfig(
            name="${ANALYTICS_DB}",
            routing_apps=["analytics", "reports"],  # Auto-route!
        ),
    }

โœ… Auto-routes read/write โ€ข โœ… Cross-DB transactions โ€ข โœ… Connection pooling

๐Ÿ“š Multi-Database Guide โ†’


โš™๏ธ Complete Configuration Example

All features in one DjangoConfig:

from django_cfg import DjangoConfig, DatabaseConfig, CacheConfig, NextJsAdminConfig

class ProductionConfig(DjangoConfig):
    # Project
    project_name: str = "My Enterprise App"
    secret_key: str = "${SECRET_KEY}"
    debug: bool = False

    # Next.js Admin (optional)
    nextjs_admin: NextJsAdminConfig = NextJsAdminConfig(
        project_path="../admin",
    )

    # Real-time WebSockets (optional)
    centrifugo: CentrifugoConfig = CentrifugoConfig(
        enabled=True,
    )

    # 8 Enterprise Apps (enable as needed)
    enable_accounts: bool = True      # User management
    enable_support: bool = True       # Ticketing
    enable_newsletter: bool = True    # Email campaigns
    enable_leads: bool = True         # CRM
    enable_agents: bool = True        # AI automation
    enable_knowbase: bool = True      # Vector DB
    enable_payments: bool = True      # Payments
    enable_maintenance: bool = True   # Site management

    # Infrastructure
    databases: dict[str, DatabaseConfig] = {
        "default": DatabaseConfig(name="${DB_NAME}"),
    }
    caches: dict[str, CacheConfig] = {
        "default": CacheConfig(backend="redis"),
    }

    # AI Providers (optional)
    openai_api_key: str = "${OPENAI_API_KEY}"
    anthropic_api_key: str = "${ANTHROPIC_API_KEY}"

    # Integrations
    twilio_account_sid: str = "${TWILIO_ACCOUNT_SID}"
    stripe_api_key: str = "${STRIPE_API_KEY}"
    cloudflare_api_token: str = "${CF_API_TOKEN}"

๐Ÿ“š Configuration Reference โ†’


๐Ÿ“Š Comparison with Alternatives

Django-CFG vs Traditional Solutions

Feature settings.py django-environ pydantic-settings Django-CFG
Type Safety โŒ Runtime โš ๏ธ Basic โœ… Pydantic โœ… Full Pydantic v2
IDE Autocomplete โŒ None โŒ None โš ๏ธ Partial โœ… 100%
Startup Validation โŒ No โš ๏ธ Partial โœ… Yes โœ… Yes + Custom
Next.js Admin โŒ Manual โŒ None โŒ None โœ… Built-in
WebSocket (Centrifugo) โŒ Manual โŒ None โŒ None โœ… Built-in
Enterprise Apps โŒ Build all โŒ None โŒ None โœ… 8 included
AI Framework โŒ Manual โŒ None โŒ None โœ… Built-in
Setup Time ๐ŸŸก Weeks ๐ŸŸก Hours ๐ŸŸก Days โœ… 30 seconds
Config Lines โš ๏ธ 200+ โš ๏ธ 150+ โš ๏ธ 100+ โœ… 30 lines

Legend: โœ… Excellent | ๐ŸŸก Requires Work | โš ๏ธ Partial | โŒ Not Available

๐Ÿ“š Detailed Comparison Guide โ†’


๐Ÿ“š Documentation

๐Ÿš€ Getting Started

โš›๏ธ Next.js Integration

๐Ÿ“ก Real-Time & Microservices

๐Ÿ—๏ธ Core Features

๐Ÿค– AI Features

๐Ÿš€ Deployment


๐Ÿค Community & Support

Resources

Links


๐Ÿ“„ License

MIT License - Free for commercial use


Made with โค๏ธ by the Django-CFG Team


Modern Django Framework โ€ข Type-Safe Configuration โ€ข AI-Native Docs โ€ข Next.js Admin โ€ข gRPC Streaming โ€ข Real-Time WebSockets

Django-CFG is the modern Django framework for enterprise applications. Built with Pydantic v2 for type-safe configuration, first Django framework with MCP server for AI assistants, includes Next.js admin integration, gRPC bidirectional streaming with WebSocket bridge, Centrifugo real-time support, AI agent framework, and 8 production-ready apps. Perfect for building scalable microservices and real-time Django applications with reduced boilerplate and enterprise features out of the box.


Get Started: Documentation โ€ข Live Demo โ€ข GitHub

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_cfg-1.5.108.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cfg-1.5.108-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file django_cfg-1.5.108.tar.gz.

File metadata

  • Download URL: django_cfg-1.5.108.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for django_cfg-1.5.108.tar.gz
Algorithm Hash digest
SHA256 4ad069442bb87860a0dec03806c695b5bab46e351985afc3a999822bb06c462d
MD5 83ff12b18c6ff05c661a4cdeb1b4eec8
BLAKE2b-256 9995d2deee89cd42ef7f586c1e3f19271d024c28de9aab9cdaf14c68ada17472

See more details on using hashes here.

File details

Details for the file django_cfg-1.5.108-py3-none-any.whl.

File metadata

  • Download URL: django_cfg-1.5.108-py3-none-any.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for django_cfg-1.5.108-py3-none-any.whl
Algorithm Hash digest
SHA256 562852558d838a803a2118ac245b316a5b70335800230e4453c6b48faf2730bf
MD5 a828c2b2f49e6a4f470b49ec81e9ffb6
BLAKE2b-256 07ee7cc8811f70028a941e4c9f8b16d10d470e94cae001385f4edbae73b5cd89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page