Next-generation Django toolkit: typed ORM, unified validation, async-first, smart caching
Project description
🚀 Django Nova
Typed, unified, and async-first toolkit for Django 5+
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 --strictcompatibility 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
CONCURRENTLYoperations for locked tables containing millions of rows. - 📊 Structured Observability: Built-in
structlogintegration 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 # 39 passed
👤 Author
Artem Alimpiev
- ORCID: 0009-0007-6740-7242
- DOI: 10.5281/zenodo.20057443
- DOI: 10.5281/zenodo.20659647
📄 License
This project is licensed under the terms of the MIT License. See the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_nova-0.2.0.tar.gz.
File metadata
- Download URL: django_nova-0.2.0.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07fd0d972ba897bd079780bd25cdcb0f490978c71149e97019a12e04a1ecad6b
|
|
| MD5 |
cb9e5ffe1257f973c3ba5da8775ec789
|
|
| BLAKE2b-256 |
5486df1c66d9b8bd0dab287bbac925167ffd53797ca5d0b1f5bdf16129848659
|
File details
Details for the file django_nova-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_nova-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58b23fdd5e22cd74a6d9977eb2bc4ceb3d0061c5a6b672b1655f5e95931a55f5
|
|
| MD5 |
c1861658b38f548798190f4e87c2e121
|
|
| BLAKE2b-256 |
52c09fa7b121352d617bf86accda19e04745125a875db019c29a41bfd1dbad5d
|