Skip to main content

Next-generation Django toolkit: typed ORM, unified validation, async-first, 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.1.tar.gz (1.0 MB 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.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_nova-0.2.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for django_nova-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0f9aabbbe45d0f32ab80f74e34b854cbdd422a343bbcf08e109e83822c546c89
MD5 8f34bc921e9829fa908155f15188be1f
BLAKE2b-256 85c5f6f905feac6352acb2a54d99845488a82b737a41c66d50fd0d5dc554b684

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for django_nova-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cca4e8d494c9dd26bc587c5749a0126747d9136760d1d103eaea6e7bcb5a5074
MD5 a0f65a63cc5ce9c33d564686e3dab7d9
BLAKE2b-256 6b1b0df22c0d9ee9bab1005e92b4baa4b4a0a6ae78bb8946fb9f4366016fae83

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