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 โ€ข 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

Installation

pip install django-cfg
django-cfg create-project "My App"
cd my-app && python manage.py runserver

What you get instantly:

  • ๐ŸŽจ Modern Admin UI โ†’ http://127.0.0.1:8000/admin/
  • โšก Next.js Dashboard (optional) โ†’ Modern React admin interface
  • ๐Ÿ“ก Real-time WebSockets โ†’ Live updates with Centrifugo
  • ๐Ÿš€ Production-ready โ†’ Type-safe config, security hardened
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)
pip install django-cfg[full]

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

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

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-Ready Infrastructure

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 (Optional)

๐Ÿš€ 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 โ€ข Next.js Admin โ€ข gRPC Streaming โ€ข Real-Time WebSockets โ€ข AI-Ready

Django-CFG is the modern Django framework for enterprise applications. Built with Pydantic v2 for type-safe configuration, 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.98.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.98-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_cfg-1.5.98.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.98.tar.gz
Algorithm Hash digest
SHA256 51d3644df1256e73fc8011580d50528cc7ee5a129640d66e4fd7b3eda4f79c0f
MD5 12b59a182f754d73a22f9d2fa3b7ae0e
BLAKE2b-256 f571feb8d81e7b47feb3a4bbed79cdb66b0d23dec3701fc03189d528126c615d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_cfg-1.5.98-py3-none-any.whl
  • Upload date:
  • Size: 2.0 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.98-py3-none-any.whl
Algorithm Hash digest
SHA256 981af2bf9fa42a9ae52cb4a3ae361382663b4296bf4f4b6e8704c9f6019bcc83
MD5 6f570a82fc4a9472dba473a34497f648
BLAKE2b-256 c3a4e66d6ce1883325f24a34cb0c6a04a43936c9f446e521468dc7bd47dddbdf

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