Skip to main content

Next-generation Django toolkit: typed ORM, unified validation, async-first workflows, and smart caching

Project description

Django Nova Logo

🚀 Django Nova

Typed, unified, and async-first toolkit for Django 5+

Python 3.12+ Django 5.0+ PyPI version Ruff License: MIT

Django Nova eliminates fundamental architectural flaws in Django that lead to data corruption, runtime errors, and maintainability issues in scientific and enterprise software.


🔑 Key Innovations

  • Single Source of Truth: Define validation once in Pydantic. Django Models, Forms, and APIs automatically read from it. No more duplication.
  • 🔒 Strict Type Safety: Full pyright --strict compatibility for ORM, QuerySets, and Models using modern PEP 695 syntax.
  • Smart QuerySet Cache: Automatic O(1) cache invalidation on write via Django signals. Zero percent stale data in research pipelines.
  • 🔄 Zero-Downtime Migrations: Native PostgreSQL CONCURRENTLY operations for locked tables containing millions of rows.
  • 📊 Structured Observability: Built-in structlog integration emitting machine-readable JSON logs with ISO-timestamps for Datadog/ELK.
  • 🔍 Distributed Tracing: OpenTelemetry spans for Model.save() and Cache operations. Zero overhead if OTEL is not installed.
  • 🔌 DRF Auto-Serializer: Generate Django Rest Framework Serializers dynamically from Pydantic schemas. Pydantic validation overrides DRF.
  • 🚀 FastAPI Auto-Router: Generate fully documented FastAPI routers with native OpenAPI/Swagger from Django models.

🚀 Quick Start

Installation

# Core library
pip install django-nova

# With DRF support
pip install django-nova[drf]

# With FastAPI support
pip install django-nova[fastapi]

# With full enterprise stack (tracing, logging)
pip install django-nova[tracing,observability]

💡 Usage Example

Define your rules once, use them everywhere:

# models.py
from pydantic import BaseModel, field_validator
from django.db import models
from nova import NovaModel, NovaConfig

# 1. Define validation rules (ONCE)
class ResearcherSchema(BaseModel):
    name: str
    h_index: int = 0

    @field_validator("h_index")
    @classmethod
    def validate_h_index(cls, v: int) -> int:
        if v < 0:
            raise ValueError("h-index cannot be negative")
        return v

# 2. Link to Django
class Researcher(NovaModel):
    name = models.CharField(max_length=300)
    h_index = models.IntegerField(default=0)

    _nova_config = NovaConfig(
        pydantic_schema=ResearcherSchema,
        cache_enabled=True,
        strict_validation=True
    )

Now, any attempt to save invalid data is blocked at the ORM level, and the schema is automatically reused in DRF and FastAPI!


🔗 Ecosystem Integration

Django Nova acts as a universal hub between Python frameworks.

Django Rest Framework

from nova.ecosystem.drf import to_drf_serializer

# Dynamically generates a ModelSerializer that delegates business logic to Pydantic
ResearcherSerializer = to_drf_serializer(Researcher)

FastAPI

from fastapi import FastAPI
from nova.ecosystem.fastapi import to_fastapi_router

app = FastAPI()
# Generates GET/POST endpoints with native OpenAPI/Swagger documentation
app.include_router(to_fastapi_router(Researcher, prefix="/api/researchers"))

🏗️ Architecture

Django Nova intercepts standard processes at the core level:

Request -> View -> Model.save() -> [Pydantic Validation -> Django Fields -> Business Logic] -> DB
                |
                +-> Cache Invalidation Signal -> Evict stale QuerySets
                |
                +-> OpenTelemetry Span -> Metrics & Traces
                |
                +-> Structlog -> JSON Logs to Datadog/ELK

Core Tech Stack:

  • PEP 562: Lazy imports bypassing AppRegistryNotReady.
  • PEP 695: Modern generic syntax (class Cache[T]:).
  • SQL Compiler: Deterministic cache hash key generation (safe across any Django version).

🧪 Testing

The project is tested on the bleeding-edge stack (Python 3.14 + Django 5.2).

pip install -e ".[dev]"
pytest tests/ -v  # 42 passed 

👤 Author

Artem Alimpiev


📄 License

This project is licensed under the terms of the MIT License. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

django_nova-0.2.3.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

django_nova-0.2.3-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file django_nova-0.2.3.tar.gz.

File metadata

  • Download URL: django_nova-0.2.3.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for django_nova-0.2.3.tar.gz
Algorithm Hash digest
SHA256 71d62e17cf1298ecd726459ce21c8ee52af9c873dc81df15732a17add5047673
MD5 d95336b3e354725772723cf1d66bfe66
BLAKE2b-256 73057b6ca95bb53cdecccb402633d94cdc50374a57c62176879763f6b0fcf3a2

See more details on using hashes here.

File details

Details for the file django_nova-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: django_nova-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for django_nova-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 113bde5ca7fe0287d4d6521b72193f55f3c9908b70f003a1133d9f403e663bfa
MD5 c9c189b93d8a1982375d46739245c88f
BLAKE2b-256 b023988a52a1d09d6faa65bf7e68da0324e24b565919add2900fd00413b63717

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