This is the best write-up of tools to use to avoid shooting yourself in the foot with Django N+1s that I have seen.
However, having used Django professionally for a while, I can say that it is really starting to show its age even if you deal with the N+1 problems. You still have to deal with:
1. Blocking database calls that cannot easily be used in an asyncio context
2. No types
3. 50% of package code being written without any regard for performance
If you're starting a project today and considering Django, I highly recommend you go with Nestjs and Prisma instead.
> If you're starting a project today and considering Django, I highly recommend you go with Nestjs and Prisma instead.
I recommend you to take a look at PostgREST. I replaced all our Django, Flask, Falcon, FastAPI and custom Python HTTP APIs with it. It's phenomenal. It's faster than any of those solutions and adding an endpoint with roles & permissions is just creating a view and executing a bunch of GRANT/CREATE POLICY (takes about 2 min of work). I'm genuinely surprised this didn't replace CRUD APIs in most Postgres shops.
Pretty rich using Prisma as a counter-example to non-performance, considering it launched without doing any JOINs – just pulled every tuple back into the engine, then filtered.
Also, Django, being Python, supports type hints just fine.
This was observed at least in 2022 [0], and wasn’t fixed until earlier this year [1].
My point was that any company willing to ship a product that is lacking such an incredibly basic part of the language does not deserve respect. These are deeply unserious people.
Nestjs has no real ecosystem compared to Django, Rails, Laravel, ASP.NET or Spring. Prisma has some nice typing but it is not even half as capable as the Django ORM.
Prisma obviously isn't as fast as the .NET ORM or raw SQL, but the MIT undergrad can throw together an app without too much worry about joins or database stuff in general.
If you have a type setup for Django and Python, I am all ears. I've spent too long trying different combinations of language servers and type plugins to get type hints for Django in VSCode and have not had any luck.
However, having used Django professionally for a while, I can say that it is really starting to show its age even if you deal with the N+1 problems. You still have to deal with:
1. Blocking database calls that cannot easily be used in an asyncio context
2. No types
3. 50% of package code being written without any regard for performance
If you're starting a project today and considering Django, I highly recommend you go with Nestjs and Prisma instead.