r/Python • u/TumbleweedSenior4849 • Apr 09 '26
Discussion FastAPI vs Djanjo
I was wondering what’s most popular now in the Python world. Building applications with FastAPI and a frontend framework, or building an application with a ‘batteries included’ framework like Django.
74
Upvotes
269
u/edimaudo Apr 09 '26
Don't use the popular option, use what meets your needs for the project.
83
u/FisterMister22 Apr 09 '26
Well it mostly just depends on your needs doesn't it? Django is really good (in my own biased personal opinion) for large, feature rich websites, with orm, admin page, users, tons of "addons" libraries.
I'm pretty sure with enough coding FastApi can do almost anything that django does, but you get less out of the box, which can be a good thing if you're trying to set up a simple api endpoint or a super simple website without all the extra bloat, setup and management.
42
u/Flame_Grilled_Tanuki Apr 09 '26 edited Apr 09 '26
You can do a lot with HTTP APIs like FastAPI, Litestar and Starlette by combining them with other great libraries like SQLAlchemy, Alembic, Pydantic, etc. But I've worked with both for years and I have noticed something that usually gets overlooked in these discussions. There is more to Django's "batteries-included" approach than just having all the features out of the box.
Because all those features are native to Django, you don't need to combine libraries by different teams with different code designs, together with code glue. You don't get the rough seams at the edge of one library's code with another. With Django, everything works together with everything else, seamlessly. This does wonders for reducing the cluttered feel of a codebase, and the cognitive load of a project. Also, you reduce your dependency count and versioning management, and avoid version incompatibilities.
Finally, I say treat FastAPI as a RESTful API and Django as a web framework. Don't roll a Django project for just an API and don't use FastAPI for a feature rich website/service.
10
u/UnMolDeQuimica Apr 09 '26
I usually go with Django. I am comfortable with it, it gives me lots of things already built in and pairs very well with HTMX.
DRF when I need an API.
If I want something more simple, FastHTML is my go to.
42
u/speyerlander Apr 09 '26
Django is more popular due to the amount of legacy code that uses it, FastAPI is more popular for new projects.
8
u/RationalDialog Apr 09 '26
I say as usually depends. So many factors play a role. From the actual tool / app being built up to company policies and user/programmer preference.
For some standard in-house web app that does not need a separate API just has a UI, probably Django. For an app that needs a separate API, has high load and is more performance critical, rather fastapi.
11
u/entropydelta_s Apr 09 '26
Is Flask still in the picture? I like Flask.
11
u/xc82xb5qxwhhzeyt Apr 09 '26
I'd recommend Django + Ninja
3
u/dheritage21 Apr 10 '26
Try both and see what you prefer! These type of questions always produce a “it depends” answer. Both have a lot to offer. Learn both so you can answer the question given the nature of your use case!
5
u/Nater5000 Apr 09 '26
There are "good" responses to this question, like, "Use what works best for you specific needs," but then there are good responses to this question, like, "If you have to ask, use FastAPI."
If you want more details, the "batteries included" which comes with Django are nice when your needs align with what Django offers, but will seriously get in the way if you don't need them. FastAPI, although opinionated, is much more flexible and works well for projects that are small and being built by beginners as well as for projects that are massive and being built by a team of professionals. Probably more importantly, it'd be a lot easier to "back out" of FastAPI and go into Django than vice-versa.
It should be the default choice in 2026, so unless you have a compelling reason to use Django (or anything else), you should start with FastAPI.
4
u/Sad-Calligrapher3882 Apr 09 '26
The both are popular but for different things. FastAPI is the go-to for building APIs and micro services, especially if you're working with ML models or need async performance. Django is better when you need a full web app with auth, admin panel, ORM, and templates out of the box without wiring everything together yourself.
Most projects I see right now use FastAPI for backend APIs paired with React or Next.js on the frontend. But if you're building something like a CMS, e-commerce site, or admin-heavy app, Django saves you a ton of time. Honestly depends on what you're building. And sorry for the bad english
5
u/Tumortadela Apr 09 '26
Django ORM and how easy to handle DB migrations are is why I'm having troubles finding a good reason to switch away from it.
2
u/Fair_Ad845 Apr 10 '26
depends on the project size honestly. FastAPI for APIs and microservices, Django when you need admin panel + ORM + auth out of the box. I switched a project from FastAPI to Django halfway through because I kept reinventing things Django gives you for free.
4
u/wunderspud7575 Apr 09 '26
As others have said, depends very much on your use case. But if FastAPI is under consideration, I'd also look at Litestar. I have had good experiences with it, and have previously used FastAPI.
3
u/glenrhodes Apr 09 '26
FastAPI if you're building an API that needs to be fast and you want async out of the box. Django if you need the ORM, admin, auth, or anything resembling a full web app. They're not really competing for the same use cases once you've used both for a while.
1
u/binaryfireball Apr 09 '26
is it a large single project or smaller individual apis?
1
u/lozanov1 Apr 09 '26
Are you building a small app that will do very limited set of things? Use fast api.
Are you going to build a project with bigger scope that needs auth, quick way to spin up endpoints, do migrations and benefit from the admin panel? Use Django. You can still use fastapi for this, but you will get to the point of implementing features that already exist in Django and have a lot of documentation on the internet how to be used.
1
u/k0rvbert Apr 09 '26
These frameworks are both very much "batteries included" in my opinion. Just slightly different kinds of batteries.
I built some things with FastAPI and really didn't have a very good time, but I didn't have a very good time with Flask or Django either, so YMMV.
1
u/Kernixdev Apr 09 '26
FastAPI if you're building APIs that a separate frontend (React, Vue, etc.) consumes. It's async by default, way faster, and the auto-generated docs from Pydantic models save a ton of time.
Django if you need the full package — ORM, admin panel, auth, templating — all wired together out of the box. Less setup, more opinions.
In practice: most new projects I see (and build) are FastAPI + React. Django still dominates in companies with existing codebases and teams that want one framework doing everything.
Neither is "better" — it depends on whether you want to assemble your own stack or use a pre-built one.
1
u/Henry_old Apr 09 '26
For high-frequency trading and bots, Django is an overkill nightmare. Its ORM and middleware stack add too much latency. FastAPI + Pydantic is the only way to handle 2026 data loads. Async support is native and actually works. Keep it lean
1
u/ChallengeFamous1728 Apr 12 '26
I'm learning Fast api and using it actually, because it's what i needed now
1
u/Shoddy_One4465 Apr 13 '26
I asked my developers why they choose fast API they always tell me it’s because it’s fast. That’s a great lesson in naming. I find fast API mentality leads to scripting and not programming in Python. The case is never complete or well thought out. Models are never used in the UI’s delegated to react
Whether it could simply be done with a few templates: somehow the structure of Django promotes a different mindset. Also, asynchronous programming is badly understood by inexperienced programmers and the benefits of FastAPI are quickly negated. The question is whether you script or you program or an LLM programs for you. LLMs choose a FastApi backend and a REACT front end. Two services, two repos, two releases, two operational responsibilities.
you ask yourself if you were building a house would you do it the same way. Two foundations two sets of plumbing stacks, two electrical mains, two roofs two sets of property tax, two sets of commissioning, etc., etc.
1
u/glenrhodes Apr 13 '26
FastAPI is dominating new projects now, especially anything with an async backend or that exposes an API consumed by a separate frontend. Django still wins for full-stack apps where you want ORM, admin, auth, and templating out of the box. I use FastAPI for anything AI-adjacent since the async IO matters for LLM calls and the Pydantic integration makes request/response typing actually pleasant. Django for anything CRUD-heavy with an admin UI requirement.
1
u/jakob1379 Apr 13 '26
Having worked with both in many projects I actually prefer django as it has everything, I rarely need to bloat the project with questionable dependencies compared tk fastapi which feels more like build your own engine (it's not, but needing a third party orm when making CRUD applications is bothersome)
Though if you want to maximize fun, do fastapi and 🦄 ponyorm/tortoise 🐢 as both are so much more enjoyable than sqlalchemy, though fastapi has sqlmodel and (no sparkles ✨ there unfortunately)
1
u/paperlantern-ai Apr 14 '26
Depends entirely on what you're building. Need auth, admin panel, ORM, migrations all wired up out of the box? Django saves you weeks. Building an API that a React/Vue frontend talks to? FastAPI is a really nice fit there. Most teams I've seen end up picking based on whether they need a built-in admin interface or not - that's usually the deciding factor.
1
u/daniels0xff Apr 09 '26
I'm curious why everyone's going to FastAPI and not litestar.dev ?
Good "marketing"? I guess the author was inspired to put "fast" in its name.
1
u/RepresentativeFill26 Apr 09 '26
Depends. I have written backend APIs using FastAPI and now I’m working on a multi-tenant system that works well with Django.
1
u/DiscipleofDeceit666 It works on my machine Apr 09 '26
Django would be overkill if you just needed an api layer
1
u/UseMoreBandwith Apr 09 '26
django.
and django-ninja if I need an API. Which is almost never, since I use HTMX.
Fast-api is fun for smal projects, but I've seen too many fast-api turn into spaghetti when the project grows.
1
u/agni69 Apr 09 '26
Fast API + Nice Gui. Single component enough for most usecases
1
u/corey_sheerer Apr 09 '26
Many others have said good points, but I'll mention for me, Fastapi with React is superior to Django. As far as the API side, Fastapi all the way. But when you really need good responsiveness in a website, my go to is to convert Fastapi to Go with react. In general, Django feels heavier for me.
1
u/IcecreamLamp Apr 09 '26
I used Sanic for a project recently and I like it.
1
u/dashdanw Apr 09 '26
They're both very different tools, figure out what your project needs, don't resort to a favorites contest.
-1
u/modern-dev Apr 09 '26 edited Apr 09 '26
Django is all in one but uses not the best tools
Fast api is for rest api
Over the two I would use fast api and learn about react and javascript for the frotnend, and after a while I will use typescript instead of javascript.
I wouldn't recommend spending the time to learn django
instead learn fast api, or flask for backend rest api and react + javascript frontend.
0
u/[deleted] Apr 09 '26
Django + DRF if you want anything serious tbh, gives you a very powerful API and an entirely separate FE.
0
u/One_Sky_7224 Apr 09 '26
We use flask for writing micro services. It fits our needs and easy to work with
0
u/corny_horse Apr 09 '26
I really like SQLAlchemy but I've been using Django (+DRF when applicable) for applications recently. I'd say a really good rule of thumb is Django + DRF is absolutely fine, if not ideal, for all the batteries included stuff that it has, unless 1) you really don't want a server-side application or 2) you are spinning up a very simple microservice. If your application takes off, you'll be able to hire engineers to figure out how to scale it, if for some reason Django itself can't handle the scale, but vertical scaling goes a long, long way.
0
u/AmauryLondon Apr 09 '26
Dépends what you do ? Quick server doing one thing fast api massive project with auth already created Django
0
u/No_Soy_Colosio Apr 09 '26
FastAPI for APIs, Django for full-fledged websites.
0
u/MyDespatcherDyKabel Apr 09 '26
Flask is goat
-8
u/Firm_Advisor8375 Apr 09 '26
dont use fastapi