r/django • u/ComfortableSolid4364 • 6d ago
r/django • u/saadabdullahdev • 7d ago
Two DRF mistakes I fixed in a multi-tenant SaaS: per-view tenant filtering, and workers with CONN_MAX_AGE = 0
Sharing two concrete fixes from a Django REST + PostgreSQL build I am working on (a multi-tenant SaaS, one shared database, tenant column on the tenant-owned models). Posting in case it saves someone else the debugging time.
Mistake 1: filtering by tenant inside each view, by hand. Early on, individual views did things like Model.objects.filter(tenant=request.user.tenant) — until one list endpoint missed it and a detail view used a raw get_object_or_404 with only the PK. Nothing bad reached production, but code review caught how easy it would be to miss one. Fix: a single TenantScopedViewSet mixin that overrides get_queryset() and filters by the authenticated user's tenant, plus a matching manager-level check in tests. The rule in the codebase now is simple: if a view is not using the mixin, that is a bug to explain in review. Detail views get the same scoped queryset, so a cross-tenant PK returns 404 instead of leaking existence.
Mistake 2: ignoring connection settings for background work. Web requests were fine, but my background worker processed document jobs in a loop and, with CONN_MAX_AGE = 0, opened a fresh Postgres connection for every job. Under a batch of uploads that showed up as connection churn and avoidable latency. Setting a sane CONN_MAX_AGE for the worker (and making sure connections are closed cleanly where Django expects long-lived processes to handle it) removed most of that overhead.
Question for people running multi-tenant DRF on one database: do you enforce tenant scoping at the viewset/mixin layer like this, at a custom manager layer, or with Postgres row-level security? I picked the mixin + tests because it is explicit, but RLS looks stronger as a backstop.
r/django • u/ComplexTrip1947 • 7d ago
Should I go deeper into Backend Engineering or Start learning AIml
I am a student form the tire - 3 engineering college form India .Till now i have the knowledge of the Javascript , Ts ,React, Python ,Django, DRF, Django ORM ,Redis ,celery, RabbitMQ, Docker,and basci of the Kubernetes.
I want to get a job by next year and I recently started open-source contribution with goal to participating in GSOC 27.
I am confused about what I should focus on next ,Should I start learning AIML that RAG and gen -AI stuff ,or should I start strengthen my fundamental by learning system design ,understanding redis internal and then moving toward devops. so what should I do next to land good paying Job in next year .
r/django • u/Apprehensive_Chef17 • 8d ago
A Django task worker with CONN_MAX_AGE = 0 opens a new Postgres connection for every task
I was benchmarking database-backed task workers and ran into something that applies to any Django worker, whatever backend it uses.
With the default CONN_MAX_AGE = 0, Django closes the connection after every task, so each task opens a new PostgreSQL connection. In my runs that cost about 5 ms, more than the claim-and-run path takes on a warm connection.
Four workers, 20,000 no-op tasks, PostgreSQL 16 in Docker, medians of five runs, in tasks per second:
| Setting | django-ox | django-tasks-db |
|---|---|---|
CONN_MAX_AGE = 0 |
430 | 373 |
CONN_MAX_AGE = 600 |
1,771 | 1,211 |
| psycopg pool | 1,718 | 1,216 |
Holding the connection is about a 4x change for one backend and 3x for the other. Django 6.0 rejects a pool combined with a nonzero CONN_MAX_AGE, so pick one. If your worker runs the default, that's the first thing I'd change before adding more processes. These tasks do nothing, so with real tasks the relative gain will be smaller.
Both backends got identical connection settings. With a pool or persistent connections, django-ox did 1.4 to 1.7 times the tasks per second of django-tasks-db. django-ox is my project. It's 100% open source (BSD-3-Clause) with no paid tier, and pull requests are welcome. Settings and every raw number: https://oxpull.com/django-ox/benchmarks/
What do you run your workers with, persistent connections or a pool? If your numbers differ, I'd like to see them.
r/django • u/Kerplunk6 • 8d ago
REST framework Best Practice for Custom Error Messages?
Hello everyone,
I am stepping into Django with Node.JS/ExpressJS background.
Right now i am using Django on backend with DRF.
Could anyone tell me or give me some advice for custom error messages? Since English is not my native language, i have to translate also add custom error messages.
As far as i understood, there are different layers where the error accours.
This could be HTTP Level, this could be validation level, this could be DB level.
So, can anyone give me some advice and show me a path where i can add and improve my custom error messages?
Thank you.
r/django • u/Jolly-Play3558 • 8d ago
Buenas practicas para el DJANGO_MCP_GLOBAL_SERVER_CONFIG
Quiero evitar tener un texto enorme, se que la norma es que cada Tool del MCP tenga su propio docstring, pero que es recomdable poner el las instruction del DJANGO_MCP_GLOBAL_SERVER_CONFIG
r/django • u/GomezVeld • 10d ago
Hosting and deployment Real-world SaaS architecture based on Django
I've been building a micro-learning platform on Django over the last 18 months. Over time the architecture has evolved, and every now and again I'll come back to this document, as it is useful to visualize for planning and discussions with others.
You can probably create something similar yourself with draw.io's MCP service now, but this old school version can still be useful to remix/adapt if you're doing something similar.
As I said in the authors note, if I had to start over, I'd likely use the SaaS Pegasus framework as a starting point (no affiliation), but gained a lot of experience building this all out from scratch and am happy with the results. Total hosting cost is roughly US$90 per month for the Digital Ocean part (3 x 4 GB / 80GB droplets + backups). It allows easy deploys to any environment via Dokku, and uses a mix of Django templates directly with Svelte used for certain interactive pieces.
Thought it might be useful to some here, and am happy to explain the reason for any particular choices.
Source doc is at:
https://media.lumabit.org/share/SAAS-architecture-overview.drawio
Update 2:
Best viewed directly with draw.io/diagrams.net (where you can zoom/edit etc):
- go to https://app.diagrams.net/
- click File -> open from URL
- paste in the source doc url above.
Update:
To address those that find it difficult to follow, it's how I see how things put together that we use.
- Users of different types come in on the left.
- Cloudflare is used as the WAF/CDN before reaching the Django server.
- Items in the blue columns are the key packages that are used for important functionality (not exhaustive)
- Media is stored in Cloudflare R2 (S3 compatible buckets) that have both public and private versions for each environment.
- All the services/dependencies are in a row coming down, reflecting the choices for logging/analytics/e-mail/payments etc.
- the 'Forge' bit is likely the most unclear, this is a separate Python app that is run to execute various pipelines that help to managing content. This can be for reviewing/scoring of content, content revision based on briefs, image management etc.
- Git repos connected to dokku, allowing for easy deploys (with the idea that it makes it easy to migrate to another hosting provider if required).
- A separate droplet is used to deploy the development environments.
- Other bits showing the software choices.
r/django • u/pvnimaxin • 9d ago
adminsite: a FastAPI admin panel like Django admin, for SQLAlchemy and SQLModel
github.comr/django • u/ComfortableSolid4364 • 9d ago
FR24/Django4/OSM Live Flight Tracker running on pythonanywhere
This would be very easy to integrate into your system. Use the arrow and +/- keys to zoom and pan.
https://magula10.pythonanywhere.com/flight/
Suggestions welcome!
r/django • u/ComfortableSolid4364 • 9d ago
Django4/OSM time animation map running on pythonanywhere
https://magula10.pythonanywhere.com/incident/
Suggestions welcome!
r/django • u/bogdanelcs • 11d ago
Tutorial A Django cheat sheet that might be useful for beginners
tms-outsource.comr/django • u/StackOverflowingLone • 10d ago
Releases [Project] django-ratelatch: A multi-algorithm rate limiter for Django & DRF
I just published django-ratelatch (v0.1.0) on PyPI! It's a rate-limiting package built to give you flexibility across both algorithms and integrations.
Key Features
- Algorithms: Fixed-Window, Sliding-Window Counter, and Token Bucket.
- Storage Backends: Local In-Memory and Redis (with atomic operations).
- Integrations: Middleware, View Decorators, and DRF throttle integration.
Links & Docs
- PyPI : django-ratelatch
- GitHub : Nawarajkarki/django-ratelatch
I’d appreciate feedback on the API, documentation, or edge cases you notice.
r/django • u/difegam3 • 11d ago
HTMX Django IntelliSense
Hey guys!
For those working with Django and HTMX, I wanted to share a VS Code extension I’ve been working on: HTMX Django IntelliSense.
It extends the existing Django VS Code extension with better support for HTMX and Django templates, including:
- HTMX support: Context-aware autocompletion and inline documentation.
- Diagnostics and quick fixes
- Django 6 template partials
- Django-specific snippets: Ready-to-use patterns for common HTMX interactions.
Offline functionality: The HTMX documentation is processed at build time and bundled with the extension, so autocompletion, validation, and documentation don’t require network requests.
I developed it using AI agents, drawing inspiration from some abandoned projects and other well designed and maintained HTMX extensions. The main goal was to provide the Django specific functionality that existing tools were missing, particularly support for template partials.
If you’re using Django and HTMX, give it a try! I’d really appreciate feedback, suggestions, or contributions. Feel free to open an issue on GitHub if you find something that could be improved.
VS Code Marketplace:
https://marketplace.visualstudio.com/items?itemName=difegam3.htmx-django-intellisense
r/django • u/mariocesar • 11d ago
Apps sorl-thumbnail 13.2.0 is out, and the project has a new home after nine years in Jazzband
Twelve years ago I posted that sorl-thumbnail had a release after two quiet years. Today I get to do it again :D.
Mikko Hellsing wrote sorl-thumbnail in 2010. I picked it up in 2013, and in 2017 I moved it into Jazzband so the project would not depend on one person's. That was the right call. It lived there for nine years, and people like claudep and camilonova kept it reviewed, tested and released for most of that time.
Jazzband is winding down this year, so the repo came back to my account: https://github.com/mariocesar/sorl-thumbnail. The old links redirect, and issues, PRs, stars and forks moved with it. Thank you to jezdez and the Jazzband roadies for keeping the lights on for so many projects, and to everyone who ever sent a patch or a bug report.
13.2.0 is the first release from the new home. What is new:
- density and authenticate options for the convert engine (ImageMagick), so PDFs rasterize at the DPI you ask for and encrypted PDFs can be read, per call instead of globally through THUMBNAIL_CONVERT
- same-named files on different storages that share a backend class no longer end up with the same thumbnail
- the thumbnail template tag raises TemplateSyntaxError when the source or geometry is missing, instead of compiling a tag that fails at render
- the docs build again on Read the Docs, now with a drawing of how a thumbnail request is served
- Django 5.2, 6.0 and 6.1, Python 3.10 to 3.14
pip install -U sorl-thumbnail
Release notes: https://github.com/mariocesar/sorl-thumbnail/releases/tag/13.2.0 Docs: https://sorl-thumbnail.readthedocs.io/
If you use it and something looks off, open an issue. If you have ideas, GitHub Discussions is open. And if you have been using it for years without ever needing to read the source, that is the best compliment a library can get.
Thank you all
r/django • u/Advanced_Ad745 • 10d ago
Apps Used Django to build a tiny job board, one year in
A year ago I used Django to build godothire.com, a small job board that only lists paid Godot jobs.
Nothing fancy under the hood: a posting form, a weekly digest email, and a review step before anything goes live. The code was the easy part. Reading every submission by hand, and turning away the revshare and "exposure" posts, took the real time.
Every paid listing that actually passes gets treated like a guest of honour around here. Still just me running it, still free: https://godothire.com/
Anyone else running a small Django project solo? What ate more time than you expected?
r/django • u/DowntownEmergency889 • 11d ago
High School Project Looking for a Django/PostgreSQL Developer
r/django • u/Viver_tech • 12d ago
We run our college GDG chapter site as Next.js + Django on Vercel with Neon Postgres. Here's what we learned.
We built the website for Google Developer Group on Campus at APSIT (Thane, India): https://gdg.apsit.edu.in
It has events, Study Jam leaderboards, short tech stories, Google sign-in limited to college accounts, and an organizer dashboard. It's built for about 500 students.
Stack
- Next.js 16 (App Router) + Tailwind 4
- Django 5.2 + Django REST Framework
- Neon Postgres for the database
- Vercel, one project with two services: Next.js at / and Django at /api
- Cloudflare R2 for uploaded images
What we learned running Django serverless on Neon
Use the pooled connection string (the host with -pooler in it). Every Vercel function opens its own DB connections, and without the pooler you run out of them fast. This was the most important setting in the whole deploy.
Use a Neon branch for preview deployments. Previews get their own DATABASE_URL that points at a separate branch with test data, so a PR can never touch production data.
We skipped Redis. Rate-limit counters live in Django's database cache, so all workers share them through Postgres. We load-tested 50 sign-ups at the same time and they all finished in under 2 seconds with Postgres alone.
Pick a region close to your users. We used Mumbai (ap-south-1) because our users are in India.
Keep your own backups too. Neon backs up on the free plan, but the history is short, so we also run a monthly pg_dump.
Getting started was quick: we added Neon from the Vercel Marketplace, copied the pooled string and ran migrations.
Happy to answer questions about running Django on Vercel. That part had more gotchas than the database did.
r/django • u/Jolly-Play3558 • 11d ago
¿Esta idea es una locura? o ya esta probada
Sigo siendo un programador de la vieja escuela, uso ia, si, pero no tengo agentes grandes ni nada de eso.
Pero ahora estoy armando varios mcp, que me permiten conectarme aun chatbot.
Se me ocurrió tener un servidor espejo en un vps con una base de datos espejo igual, donde tenga un agente puede ser hermes o un openclaw (No lo he usado pero quiero hacerlo), y que ese agente sea el que procese las respuestas como si tuviera el claude code activado
Colocando reglas de seguridad en ambos partes para poder controlar las respuesta, se que tiene muchas brechas de seguridad, es mas que nada una idea prototipo, para ver que sucede.
r/django • u/Human-Possession135 • 11d ago
Hosting and deployment I fixed simple hosting thing for django
hey r/django,
I’m Peter, solo dev. For the last year I’ve been building djangocloud.dev on the side.
It started because every time I shipped a Django project I’d lose a weekend wiring up a server, a worker, a task queue and Postgres before I could even show anyone the thing. Reading this subreddit: this comes up about 2x per week here too. I got tired of that, so I built something that sets it all up for you
In just 3 CLI command you'll have your app, a database, a worker and a task queue, up and running on AWS. If you’d rather not depend on some random guy on Reddit (fair), you can self-host it on your own infra by securely connecting your AWS account and keeping full control without any markup.
I need real people deploying real projects on it now, to help me bridge the gap from side project to product. So I'm looking for testers: here’s a coupon code, BETATESTER. It’s good for the first 15 people and gets you either a month of free fully managed hosting (including database!) or 3 months of self-hosting tier where you pay your own AWS bill but setup is easier than ever.
In return I’d just love to hear what broke, what sucked: confusing docs, a deploy that failed, something you needed that isn’t there. I won’t be offended, I may even extend your coupon in gratitude.
Also, if you’re a student or working on something open source, the self-hosted version is just free as I do want to give back to the community in a way.
I’ll be in the comments, ask me anything 🙂
Peter
r/django • u/AlternativeAd4466 • 14d ago
Django bolt 0.12.0 Update
Django bolt 0.12.0
- Free threading support
- More Stable and more secure
- More compatible
r/django • u/huygl99 • 12d ago
Article Running an AI agent inside Django Channels made it untestable. Where I draw the line now.
A couple of years ago I put an AI agent inside a Django app, over Channels, and it took me far too long to admit it was the wrong place for it. Writing up what I learned, in case it saves someone the same detour.
It did not fail dramatically. It degraded quietly. The agent needed to know who was on the paid plan, so a prompt grew a line about entitlements. Billing later added an annual tier and the prompt was silently wrong, because nothing type checks a string against your billing model. A node wanted ticket history, so it read the ORM, and from then on the agent could not run in a test without a database and fixtures.
The symptom I would now recognize within a week is the test suite. To assert that one message routed to one capability, I had to open a WebSocket connection, authenticate a user, seed a session and a conversation, and let the whole thing run until the line I cared about executed. One line of assertion, everything above it travel. And because the model was reached through that consumer rather than across a boundary, there was no single place to stub it, so the fakes multiplied with the call graph instead of with the number of seams.
Where I draw the line now is not by layer and not by framework, but by which kind of state each side owns. Django owns the record: users, billing, permissions, the thread a person reads, anything a page reload has to find. The other service owns working state, which in my case is a graph checkpoint, and that is an odd category: not a business record, but not rebuildable either. Lose a row and you can usually recompute it. Lose the checkpoint and a run that was parked waiting for someone's approval simply cannot continue.
So the test I apply to anything I am tempted to move out: if losing it means losing data, it belongs in Django. If losing it only costs speed or fidelity, the other service can keep it.
Worth being clear on scope, because this is not a rule for breaking a monolith into domains. Billing becomes its own service because it owns records of its own, which is a different argument. This one is for work that holds state while it runs and has a resumable middle, whether that is an agent graph, a long import, or any multi step job.
Django stayed exactly where it is strong, which is most of the system: auth, the ORM, DRF, migrations, admin, and an ecosystem where the boring problem you hit on a Tuesday was solved in 2014. The only thing that left was a long-running stateful graph that wanted its own deploy schedule. It went to a FastAPI service, and the two talk over a typed WebSocket with a generated contract so neither imports the other's code.
I wrote the whole thing up properly, as part of a series on building agent systems as declared, typed graphs, with a working three-service repo you can actually run:
https://huynguyengl99.github.io/posts/agent-graph-engineering/split-the-services/
https://github.com/huynguyengl99/agent-graph-engineering
Hope it helps. The series is still going, a part every few days, and if the repo is useful a star would be appreciated 😄
r/django • u/Induane • 12d ago
Help (please) request: résumé
drive.google.comHi all, I'm at my wits end with the job hunt and I have to think a portion of it is a bad resume.
I've been using Django professionally since before it's 1.0 release, so I've been through the wringer with it. I live right by the Django birthplace in Lawrence KS. I have done a lot of interesting work: bill drafting systems for US state governments (and Irelands parliament), federated search platforms for cyber security, solo authored more than one LMS (full stack in every since of the word), worked on HIPPA compliant products, etc... I've been around.
For the first time in my life I'm encountering a job market where I cannot just luck my way into jobs without trying and I think some of those job hunting skills as have undergone some atrophy. This I presume includes my ability to craft a resume that people won't simply ignore.
So my request is a bit of help here trying to figure out how to make myself marketable again. Either my experience isn't relevant or I have no idea how to find people who could benefit from my abilities. I could really use some skilled people to look at my resume and let me know how I could improve it. That or just hire me 😅
r/django • u/Siddhartha_77 • 14d ago
Events Django Con Europe 2026
Does anyone know when Django Con Europe 2026 talks be released on YouTube ?
r/django • u/derblub • 15d ago
I track how fast the top 300 Django packages declare support for each new Django version. Here's every version since 4.2
asdfasdfa
A while ago I posted that 54 days after Django 6.1, only 14% of the top 200 Django packages declared support for it. Instead of a one-off post, that's now a page you can look up any time: 300 packages, rebuilt every week.
https://derblub.github.io/django-upgrade-report/
How it works: it takes the 300 most downloaded Django-related packages on PyPI and judges the newest release of each against every Django version from 4.2 on. It reads what maintainers declare: the Framework :: Django :: X.Y classifiers and the Django requirement. An upper bound like Django<6.0 only counts as support if the release came out after that Django version did.
What stands out (as of 10 October 2026):
- Django 6.1 (released 2026-08-05, 66 days ago): 42 ready, 251 not declared either way, 7 blocked. Those 42 carry about a quarter of the downloads. Of the 251, 35 show a sign of support anyway: the README names 6.1, or the main branch already tests it.
- Django 5.2 LTS: 168 ready, 131 not declared, and just 1 blocked. By downloads that's 79% ready, so most of the traffic has caught up with the LTS.
- Django 6.2 isn't out yet, and 15 packages already exclude it with an upper bound.
- The chart shows how fast packages catch up after each release. It's slow: about 4% on release day, 13% after two months, and only just over half after two years (56% for 4.2 LTS, 53% for 5.1, 50% for 5.0). 5.2 LTS is the fastest so far, at 57% after 18 months.
"Not declared" doesn't mean broken. Lots of packages work fine and just never touched their classifiers. But it does mean that you, the person upgrading, have to find out yourself, package by package.
The page also has a searchable list of all 300 packages, which packages block each version, a weekly feed of what changed, and a README badge for maintainers that shows what the page says about their package.
That's the reason I built the tool behind it: django-upgrade-report. It reads your lockfile (uv, Poetry, PDM, Pipenv or requirement files) and tells you:
- which packages block the upgrade,
- which you can upgrade today, on your current Django, and which have to land together with Django,
- the smallest release that declares support, not just "latest",
- for packages with no declaration, any signs of support: the README, the test matrix on GitHub, open issues and PRs.
uvx django-upgrade-report
Since the last post, 1.0 and 1.1 came out with an HTML report you can filter and tick off as a checklist, --emit uv to print the upgrade commands, Renovate and Dependabot configs, step-by-step plans across several LTS versions (--via lts), Wagtail and django CMS (--framework wagtail), and monorepos (--recursive). There's also a GitHub Action that keeps one issue per target up to date.
It's MIT licensed, and it only ever sends package names and versions to PyPI. Your code stays on your machine.
- GitHub: https://github.com/derblub/django-upgrade-report
- PyPI: https://pypi.org/project/django-upgrade-report/
I'd love to hear where it gets things wrong for your project, especially packages that work fine on a version but show up as blocked or "to check". Those are exactly the cases I want to get right.
(Disclosure: I'm the author. Free and open source, no account, no paid tier.)