Django Utils

CI PyPI version Python versions Documentation

Django Utils is a collection of the small Django helpers, admin power-ups and ORM utilities that most projects end up writing themselves: JSON-aware admin filters, encrypted model fields, memory-bounded queryset iteration, resumable management commands, and more. It is by no means a complete collection, but it has served production projects well and keeps growing.

Admin power-ups

Filters (including JSON sub-path and operator filters), the validating JSON widget, read-only admin, sortable count columns, and CSV/JSON export.

Admin power-ups
Models & fields

Slug/__str__ mixins, metadata-carrying choices, Fernet-encrypted fields, and a native PostgreSQL enum field.

Models & fields
QuerySets & bulk

Memory-bounded queryset_iterator, fan-out-safe subquery aggregates, and chunked upsert via bulk_update_or_create.

QuerySets & bulk
Management commands

ChunkedCommand: resumable, checkpointed processing of large querysets with progress logging and a transactional dry-run.

Management commands
Middleware & context

ASGI-safe request/user context, Fetch-Metadata CSRF hardening, auth decorators, and production-safe query budgets.

Middleware & context
Why django-utils2

What it does differently from django-extensions and django-model-utils, and the quality gates every release has to pass.

Why django-utils2

Quickstart

pip install django-utils2
INSTALLED_APPS = [
    ...,
    'django_utils',
]

The quickstart walks through the first three features worth enabling.