#django
Django framework, libraries, patterns
Writing
- Django ORM: From sync_to_async Threads to Native psycopg3
A deep dive into how Django's ORM became truly async — how the old thread-pool approach worked, what changed in Django 6.0 with psycopg3 and ContextVar, and why asyncpg was left out.
- Django Native PostgreSQL Connection Pooling
Configure Django’s native PostgreSQL connection pool with psycopg, handle connection cleanup, and measure performance before and after.
- Handling Django Authentication Redirects in HTMX Applications
A clean solution for handling Django authentication redirects in HTMX applications, preventing login forms from appearing in the wrong place when sessions expire.
TIL notes
django-bolt decides where your code runs by reading it
django-bolt serves Django from a Rust server, with one Python worker thread per process. In an independent benchmark it ran 1.6 to 1.7x django-ninja on real database endpoints. The catch: a slow sync handler must move to a thread pool, or every request in that process waits. Bolt decides at startup by scanning each handler’s source for ORM calls like
.objects.get.The scan reads only the handler.
return Order.objects.get(id=id)goes to the pool.return services.get_order(id)runs the same query inline on the worker thread, and the whole process stalls until it returns. A codebase with a service layer hits this on nearly every route. The way out is async handlers:async defputs the waiting in the signature, so it can’t hide one call down.A scan of one function sees what’s written there, not what it calls. A fact that has to cross calls belongs in the signature, which is Ron Minsky’s argument for types.
Django Seedkit
viewflow/seedkit is an agent skill that scaffolds a Django project by asking you questions, then writes only the parts you picked. The edge over cookiecutter: it also works on a live repo.
/django-seedkit add proper authinventories what exists and wires the new package in midway: deps, settings,.envexample, CI step. A deterministic generator runs once, on day zero.The layout is the part worth copying. One
SKILL.mdwalks the questions and routes each answer to exactly one file inreferences/(auth.md,billing.md,tasks-celery.md, about 50 of them). Each file keeps only what the model gets wrong: current setting names, current packages. Their benchmark: Sonnet 5 with the skill passed 72 of 72 security and config checks across nine projects; Fable 5 without it missed about a quarter.The pattern generalizes past Django: one orchestrator skill that asks the questions, plus a reference pack per stack (Django, Next.js, Flutter). Seedkit ships only the Django pack today.
django-ox
django-ox makes the database the Django task queue: transactional enqueue inside
atomic(), no Redis/RabbitMQ, retries, worker-death recovery, recurring schedules, admin and metrics. Adoption read: pilot it for ordinary Django jobs; keep Celery for broker-scale workflows.django-crawl
django-crawl by Adam Johnson: BFS-crawls your Django site using the test client, no real HTTP overhead. Origin story: diffing CSP headers during a Django 6.0 migration accidentally caught 7 non-CSP bugs in a 100%-coverage project. HTML parsing via Rust (html5ever), follows links/sitemaps/feeds. Works as a management command or a TestCase smoke test that raises
ExceptionGroupon errors.Django Modern REST
Django Modern REST seems to be an emerging REST API library with focus on performance, scalability and pluggable serializers. Supporting msgpack, CBV and less of sync_to_async. Might evaluate it against the my current preferred
django-ninja. geminizoocache
Django Postgres Migration Tools
“Django Postgres Migration Tools - add-on for safer and more scalable migrations in django.
Django rapid architecture
Notes from “Django rapid architecture”
- Recommends organizing the codebase with interfaces at the top layer followed by readers and “actions”, Finally, ‘data’ as the bottom layer to organize Django codebase to allow for a simple code structure that allows for scaling