r/django

▲ 8 r/django

Why is my Django server slow

I have been build a web application using django as backend server and postgres Sql. I haven't hosted my server on AWS both I am testing it locally and in my opinion it is taking 1.5 sec to go from one route to another. How should I optimize my django server for better response

reddit.com
u/Old-Raspberry-3266 — 5 hours ago
▲ 49 r/django

django application with t3.micro can handle a lot of traffics..

I made an ecommerce website using django and have run for 2years. At first time, I was quite afraid that t3.micro is not enough for my django backend server. However, these are what I experienced for 2years of running it..

specs are:

backend : t3.micro / django5.0 / python 12

db : t3.micro / RDS PostgresQL

cache : redis(elasticache)

- I got about 20k~40k visitors a month, t3.micro backend server can handle even without any of cpu or memory spikes.. most of the time, cpu usage stays at 3~5%.. 10~15% for peak time..

- sometimes I got 50~70 concurrent users and t3.micro can handle without scale out and my app does not show any performance drop..

- no async, I use only restframework and still it is quite fast enough. page load takes 1.5sec, most of request takes 30~50ms.

reddit.com
u/SnooCauliflowers8417 — 21 hours ago
▲ 25 r/django

Is Django still a good choice?

I’ve been learning backend development and currently focusing on Django.

But I keep seeing mixed opinions about it in the job market.

Some say it’s still widely used and good for getting jobs, while others suggest that Node.js or other frameworks are more in demand nowadays.

So I wanted to ask:

  • Is Django still a good choice for entering the backend job market today?
  • What types of companies usually hire Django developers?
  • Should a beginner stick with Django or switch to something like Node.js?

Would appreciate real-world insights from developers working in the industry 🙏

reddit.com
u/Om_JR — 2 days ago
▲ 7 r/django

Built a Django app for a client – no idea how much to charge. Need pricing advice.

I just finished a Django project by vibe coding – but not with Cursor. I pasted everything into files manually, line by line. So I actually understand the basics and how everything fits together.

Project features:

  • Login / Signup
  • Examination page
  • Custom admin panel with tabs for dashboard, exam config, key sessions, student records, and question CRUD (multiple choice, true/false, abstract reasoning)

Stack: Bootstrap + SQLite

The client wants it fast, and I also want to learn Django more deeply.

My questions:

  1. How much should I charge for this (Philippines rates)?
  2. What should I learn next to level up from beginner to intermediate? Specific topics, projects, or resources would help a lot. Also – how do you actually learn them effectively?
reddit.com
u/CEENNNNNN — 2 days ago
▲ 0 r/django

Where do you get Frontend to use it with DRF

I am building a booking app like my own pet project with Django Rest and I want to visualise my json dicts into something real

reddit.com
u/Lumpy_Illustrator365 — 2 days ago
▲ 0 r/django

Django migrate keeps failing in CI with duplicate column/table errors — so I wrote a self-healing wrapper that detects the failing migration, fakes it, and retries

If you've run Django migrations on MySQL in CI long enough, you've seen this:

django.db.utils.OperationalError: (1060, "Duplicate column name 'some_field'")

Schema drift between environments, a migration applied manually, a botched rollback — whatever the cause, the pipeline is now broken and someone has to SSH in, figure out which migration to fake, run it manually, and retry.

I got tired of doing that so I wrote a wrapper around manage.py migrate that handles it automatically.

What it does:

Runs migrate normally

If it hits a duplicate column/table/key error (MySQL 1050, 1060, 1061, 1068, 1091) — parses the output to identify the failing migration, fakes it, and retries

If it hits InconsistentMigrationHistory — deletes the offending record from django_migrations and retries

Any other error — stops immediately so you don't mask real problems

Loops until all migrations are applied successfully or an unhandled error stops it

What it doesn't do:

Won't blindly fake everything — only fakes the specific migration that caused the error

Won't swallow unrecognised errors

MySQL only — relies on MySQL error codes

https://github.com/chiragJoshi24/Django-AutoMigrate/

Curious if others have hit this — how are you handling migration drift in CI?

reddit.com
u/chirag45610 — 2 days ago
▲ 0 r/django

Django migrations were blocking our writes on 50M+ row tables — so I built a schema sync tool that skips them entirely

At work we run Django on MySQL at ~900 req/s, and Django migrations became a real pain point:

ALTER TABLE on large tables acquires full locks — we've had deploys block writes for minutes Migration history gets messy across environments No easy way to preview what DDL will actually run before committing to it Rolling back a bad migration on a 50M+ row table isn't fun

So I wrote a ~400 line Python script that diffs your Django models against the live DB schema using INFORMATION_SCHEMA and generates only the minimal ALTER TABLE statements needed. No migration files, no migration history table, no makemigrations/migrate dance. What it does:

Compares every model field against the actual DB columns (type, nullability) Adds missing columns, drops removed ones, modifies changed types Handles GeneratedField (MySQL virtual/stored columns) Drops FK constraints before modifying dependent columns (avoids MySQL errors) Syncs indexes: db_index, unique, Meta.indexes, unique_together Dry-run mode (--dry-run) to preview the exact SQL before touching anything Skip list for apps you manage manually (Wagtail, CMS, etc.)

What it doesn't do (intentionally):

No data migrations — schema-only No migration history tracking — it's idempotent, run it anytime No Postgres/SQLite support — MySQL-specific INFORMATION_SCHEMA queries No rename detection — a rename looks like a drop + add

Example dry-run output: ALTER TABLE users_profile ADD COLUMN last_active DATETIME NULL; ALTER TABLE orders DROP COLUMN legacy_status; ALTER TABLE products MODIFY COLUMN price DECIMAL(12,2) NOT NULL;

https://github.com/chiragJoshi24/Django-Migrate-Lite

Would love feedback — especially if you've dealt with similar migration pain at scale. Is this something others would find useful as a pip-installable package?

reddit.com
u/chirag45610 — 2 days ago
▲ 0 r/django

Is this Query Leak?

https://preview.redd.it/q5gdp6srq6wg1.png?width=1215&format=png&auto=webp&s=3b6f21edf9c7afe022308828523cf4258bcd3ad8

Hi, is his query leak? The number of DB Total queries goes down after restart. How would you debug where could be the issue? I suspect there might be issue with the celery, I am running task every minute there, but does not correlate well as there are sometimes "empty spaces" where the leak does not happen or there is some query 4x in one minute. I tried to debug it to see what's happening but it's useless. AI doesn't know shit also (as expected). I also tried to revise every part of code and what I thought would fix it has failed so far ...

About my project, it is Python 3.12, django 5.2, running celery 5.5 / I am running this as my pet/side project and cant pinpoint with what commit did this happened first as my retention on prometheus does not get that far.

I am using https://github.com/django-commons/django-prometheus for collecting the data and the query you see is as follows:

sum(irate(app_django_db_execute_total[$__rate_interval])) by (vendor)sum(irate(app_django_db_execute_total[$__rate_interval])) by (vendor)

Any ideas? I'm out of them.

reddit.com
u/THEGrp — 2 days ago
▲ 19 r/django

Django Styleguide

Hi! A bit of self promotion. Folks on this reddit are asking from time to time about django architecture. I use a variant of original HackSoft styleguide with some modern async flavors: https://github.com/pySilver/django-styleguide

I don't chase github stars so if you have any negative emotions regarding this post - simply ignore it.

P.s. I will be updating the styleguide to migrate from django ninja to soon (https://github.com/wemake-services/django-modern-rest)

u/silveroff — 3 days ago
▲ 30 r/django

Most Celery tutorials cover the basics, but they rarely mention what can go wrong when publishing a message.

A common pattern I've seen across teams: a task gets queued, something silently fails on the publishing side, and the debugging session starts with no traces and no clear recovery process.

After running into these issues repeatedly, I mapped out six stages of reliability for Celery/RabbitMQ setups:

  1. Best Effort: fire-and-forget, at-most-once delivery, tasks can vanish silently
  2. Transactional Boundary: wrapping commands in atomic transactions to prevent out-of-sync data
  3. Publishing on Commit: using delay_on_commit so tasks aren't queued before the transaction succeeds
  4. Publisher Confirms: getting actual confirmation that the broker received and persisted the message
  5. Outbox Pattern: persisting intent to the database first, dispatching later, giving you at-least-once delivery
  6. Clusters and Quorum Queues: replication strategies and where classic queues can still lose messages

Full write-up here if useful: https://vladogir.substack.com/p/your-background-tasks-are-silently?r=157avd

Next, I plan to cover the consumer side: idempotency, monitoring and observability.

What do you think I missed?

u/Fragrant_Brush_4161 — 3 days ago
▲ 0 r/django

Does AI will replace developers?

Recently I posted on this sub-reddit asking suggestions on Django project ideas. I wanted to start my first Django project, hence I asked. On my computer, I was testing and playing with local LLM models using tools like ollama and LM Studio. Few days ago, Google released Gemma 4 series of open models. So I downloaded Gemma 4B model and started testing it. Till now, I only used ChatGPT and Claude chatbots. But I didn't know about agentic coding tools until today which blowed my mind and and let me question myself. Is it worth learning coding? Would AI replace most developers? I think so. Let me tell you what happened and how my Django project is connected to this.

While playing with Gemma model, I saw youtube videos to know it's capability and also how can I use it locally. I saw people are using it with Claude code. This is the first time that I got to know about it. I believed all those tools are for subscribed users and for Enterprise companies. On YouTube, I got to know that we can use local models with Claude code. So I tried Claude Code using Gemma 4 model. It didn't work well. I checked YouTube and got to know that Qwen 3.5 9B models is best local model for agentic tasks. Gemma model had some problem. So I downloaded that in LM Studio and used with Claude code. Now I wanted to test it. So, I asked it to build me a fully functional e-commerce Django project with orders, order history, users, items and etc...and told it to ask me if it requires any more information. It asked me questions on the project like : do the project need to be basic or fully functional with advance features, what type of database to use and what type of UI etc. Then it started coding. I gave all permissions to run in terminal. It took like almost close to an hour. It created complete Django project. I was shocked. I checked the project files. It created all files.

I tried to run it. But there are errors. Okay now I thought may be the model is not capable enough. And wanted to drop further testing. At this moment, on twitter Open AI posted they released a new version of their agentic tool called Codex. Says it's a free app for windows and Mac OS. I downloaded it and it looks similar to ChatGPT but with many options. So dropped the Django project folder in it and said that this project is a Django web application but when tried to run, getting errors and asked it to fix all the errors.

It read whole project and all the files in it and started fixing each error by itself. It took like 5 to 10 minutes. Now I tried to run the project and to my surprise the Django app was running perfectly. The app contains User registration, orders, items, order history and everything is working fine.

This was a huge surprise. I wanted to start a Django project myself and I know that it may take few weeks or more to atleast bring the project to a proper shape. But these agentic tools are doing all that within hours. If AI can do all this with simple instructions in English then wouldn't it replace some developers like entry and junior developers in companies? What about jobs for those roles? Thanks for reading this. I would like to know your thoughts on this topic.

reddit.com
u/swaroop_34 — 3 days ago
▲ 5 r/django+1 crossposts

Built a python toolkit for easy data extraction

Scout is a Python toolkit for working with the web as a data source — combining browser automation, crawling, structured extraction, and optional LLM agents into one flow.

It sits on top of Playwright, but abstracts away the usual glue code.

What it does:

  • Scrapes pages and returns a structured Document (HTML + metadata)
  • Runs browser actions like click, type, scroll, and execute JS
  • Crawls sites with depth, filters, and concurrency controls
  • Converts raw HTML into clean markdown
  • Extracts structured data using schemas (no LLM required)
  • Uses agents for complex or dynamic pages when needed

Core idea:

Start deterministic (DOM, selectors, schema),
and only use agents when the page gets messy.

In short:
one abstraction to replace scraping scripts, crawling logic, parsing code, and ad-hoc LLM pipelines.

Here is a snippet of how I extracted my playlist

https://preview.redd.it/6gy9ddio0zvg1.png?width=3680&format=png&auto=webp&s=1c1bb7213c9a8351e0dc093cd5cf6f87acc71304

reddit.com
u/AffectionateWar5927 — 3 days ago
▲ 0 r/django

Got stucked

Hey everyone

I am new to Django and I just hit a stumbling block...

So, I am following Code aur chai for Django(as it is the latest yt course I can find) and...I installed Django tailwind and did everything instructor did...

but my tailwind doesn't seem to apply in my browser.

When I inspect the code, I can see tailwind able to be loaded but it's not applying .

Did anyone else experienced it?

or can someone guide me how to resolve it?

reddit.com
u/NumerousManager2708 — 2 days ago
▲ 2 r/django

Need suggestions on project idea

I learned Django framework and wanted to start a project on it. But I am stuck on fixating a project idea. I want to build an useful app. I see that there are many e-commerce based projects. For the first timer like me, I want mine to stand out from the rest and build an useful app that people want to try and use it. It gives a great satisfaction for anyone whose app is used or liked by many. With this context in mind, I request you people to suggest be some ideas. If you feel like someone should build an app to fix a problem that many users face, please tell me. If not me there are many wonderful people here, who may pick that problem and build an app. Thanks in advance.

reddit.com
u/swaroop_34 — 4 days ago
▲ 0 r/django

From 2000 users to almost none: are handcrafted apps getting buried?

Two years ago, my friend and I launched a football prediction pool for the Euros with a twist. In a lot of pools, you can keep predicting boring scores like 1-0 and do surprisingly well.

So we built our own system to make it more interesting: correct predictions would score points based on how unlikely they were. A predictable result would be worth less, while correctly calling a surprise scoreline would earn more. We used team ELO ratings and statistical models to estimate score probabilities, then based the scoring on those odds.

At first it was just for our own friend group, but when we made it public for the Euros 2024, it actually took off more than we expected. We ended up with around 2,000 users, which felt huge for a small side project built mainly for fun.

That momentum made us think we were onto something. So this year we went further: we relaunched under a new name, Goalguessers.com, and even built both Android and iPhone apps to make it feel like a proper product instead of a one-off tournament tool.

But now the opposite is happening. Two years ago 2,000 people joined. This time, almost nobody is. Is the internet so flooded with AI products now that nobody notices handcrafted apps?

reddit.com
u/Pacemates — 4 days ago
▲ 0 r/django

I just added Google Sign-Up/Login to my Django project using OAuth2 (django-allauth)

Setting up credentials in Google Cloud

Callback URL mismatches

Understanding the auth flow

u/Thank_Japan — 2 days ago
▲ 2 r/django

How I protected my Django REST API with custom throttling — login was wide open to brute force

I was building a Django REST API with JWT auth and realized

my login endpoint had zero rate limiting. Anyone could

attempt logins as fast as their connection allowed.

DRF's default throttling puts the same rate on every

endpoint. That makes no sense — your public feed endpoint

and your login endpoint are completely different threat

surfaces.

Here's the fix I used — custom throttle classes per endpoint:

from rest_framework.throttling import AnonRateThrottle

class LoginThrottle(AnonRateThrottle):

rate = '5/minute'

scope = 'login'

class OTPThrottle(AnonRateThrottle):

rate = '3/minute'

scope = 'otp'

class PasswordResetThrottle(AnonRateThrottle):

rate = '5/hour'

scope = 'password_reset'

Then apply per view:

class LoginView(APIView):

throttle_classes = [LoginThrottle]

def throttled(self, request, wait):

raise Throttled(detail={

"message": "Too many attempts. Please wait.",

"wait_seconds": int(wait)

})

The wait_seconds in the error response is important —

your frontend can show a real countdown instead of a

generic error message.

Three things I learned:

  1. 5/minute on login is more than enough for real users

  2. Always test throttling with pytest — loop requests

    until you hit 429 to confirm it's actually working

  3. If you run multiple servers, use Redis as your cache

    backend or throttling won't work across instances

I wrote the full breakdown with pytest examples and

Redis setup here:

https://learnpython-xi.vercel.app/post/0c469fda-d843-4d87-9ca1-0a606387d84e

Happy to answer questions — been running this in

production for a few weeks now.

reddit.com
u/BothZookeepergame285 — 2 days ago
🔥 Hot ▲ 69 r/django

How are you handling background tasks in Django right now — is Celery still the default?

Trying to get a clearer picture of what people are actually running for background task processing in Django projects right now. Celery has been the go-to answer for so long that it's worth asking whether that's still the right first choice or just habit at this point.

For smaller projects, Celery is a lot of infrastructure for what might be a handful of async tasks. Redis or RabbitMQ as a broker, worker processes to manage, monitoring to configure — it works, but it's not lightweight. Django-Q and Huey come up as alternatives and seem more self-contained, but it's hard to get a real sense of how they hold up under any meaningful load without having run them in production.

Django 4.x also brought native async improvements, which raises the question of how much people are actually leaning on that versus still reaching for a dedicated task queue. Native async probably doesn't replace a proper queue for scheduled jobs or retries, but curious whether that assumption holds for people who've dug into it.

What are people actually running in production right now? Is Celery still the obvious answer for most use cases, or are there setups where something lighter genuinely holds up? And for anyone who has switched away from Celery — what drove that decision and was it worth it?

reddit.com
u/alexstrehlke — 7 days ago