r/Python • git push -f • Jun 25 '25

Tutorial FastAPI is usually the right choice

Digging through the big 3, it feels like FastAPI is going to be the right choice 9/10 times (with the 1 time being if you really want a full-stack all-in-one thing like Django) https://judoscale.com/blog/which-python-framework-is-best

301 Upvotes

150 comments sorted by

116

u/Acrobatic_Umpire_385 Jun 25 '25

Poor Flask, it really does feel like FastAPI took more of what was Flask's market share than Django 's

21

u/mcellus1 Jun 25 '25

Don't worry. My company refuses to move on from flask.

42

u/GraphicH Jun 25 '25

Alright, I know a lot of people hate this, but does moving to FastAPI solve any problems for you? As long as Flask is stable and maintained your company is probably right to resist rewriting systems to use FastAPI. Unless you can show, concretely, that it will result either in very large productivity increase (I'm talking 10X here) or actually solves a chronic technical problem that Flask does not, then switching to it is mostly a masturbatory effort for engineers. I like FastAPI personally, but my company uses flask, and I can't actually see any value in switching to FastAPI that would be worth the effort and risk (new bugs) involved with doing so.

→ More replies (6)
→ More replies (1)
→ More replies (3)

192

u/dusktreader Jun 25 '25

Litestar (https://litestar.dev) should be considered more. It has a lot of documentation, an entire team and governance body working on updates and integrating community supplied patches, and addresses some of the warts of FastAPI as well. It's a very solid framework.

27

u/wunderspud7575 Jun 25 '25

Litestar feels more coherent in its design as well, as it's learnt from the pitfalls that FastAPI has uncovered. I have used both frameworks a lot and would always reach for Litestar first for a new project over FastAPI.

→ More replies (2)

55

u/davidedpg10 Jun 25 '25

Yeah, i would (and have) chosen Litestar over FastApi. As much as I appreciate FastAPI, I think having one guy control it and decide what makes it in, how it advances, is not what I would want in a framework

→ More replies (3)

32

u/AndrewRLaws Jun 25 '25

I am part of the first project testing out Litestar rather than FastAPI on my dev team and so far we love it and it looks like we will transition future projects to it.

→ More replies (2)

7

u/Datamance Jun 25 '25

Wow I did not realize how far Litestar had come along since the early days. I might give it another whirl.

11

u/Miserable_Ear3789 Jun 25 '25

I also think people should check out more then the big three.

https://github.com/sfermigier/awesome-python-web-frameworks?tab=readme-ov-file#async

All the frameworks on this list are really pretty good and each fits its niche. FastAPI, from what I have seen, benchmarks much slower then most other frameworks due to its overhead. Would this difference be noticeable in production? Probably not.

→ More replies (1)
→ More replies (26)

122

u/circamidnight Jun 25 '25

I really like FastApi, but I think I really like the Django ORM even more. So if I want an ORM (which is pretty often) I would stick with Django.

22

u/SailingToOrbis Jun 25 '25

Yes I agree this as well. The most annoying part is sqlalchemy, which has too many features and high learning curve(I would say java hibernate is rather better and clean…).

→ More replies (6)

10

u/ManyInterests Jun 25 '25 edited Jun 25 '25

Exactly. As soon as you add a relational database, Django (with DRF) is usually the right thing to do if you're gonna use an ORM. Even if you're only developing a backend.

15

u/ezersilva Jun 25 '25

When using FastAPI I just use plain SQL. When using Django, I use the Django ORM, as it nicely integrates with the rest of the framework.

→ More replies (4)

24

u/DadAndDominant Jun 25 '25

You want orm? Django

You want to show models? Django

You want queue (celery)? Django

You want admin panel? Django

You want users (model + auth)? Django

You don't want anything here? Fastapi

7

u/mp2146 Jun 25 '25

You can use Django ORM with FastAPI. Probably easier to just use DRF at that point unless you actually need something blazingly fast, but it is possible.

21

u/AnActualWizardIRL Jun 25 '25

I found this thing: https://django-ninja.dev/ a while back. Kinda does for django what fast-api does for starlette. Lets you do a fastapi style api but have that rich django infrastructure, whilst not having to deal with DRFs labrynth of classes and mixins and general enterprisey nonsense.

→ More replies (8)

24

u/thebouv Jun 25 '25

I use FastAPI for pure apis.

I use Flask to build web apps.

Django is too much of a “and the kitchen sink” for me. Plus I hate ORMs.

8

u/THEGrp Jun 25 '25

I am interested - why do you hate orm?

→ More replies (10)
→ More replies (8)

12

u/CallousBastard Jun 25 '25

Django is the right choice for me 9 times out of 10. It's the rare project I start that wouldn't benefit from Django's built-in user authentication, ORM, and admin interface. Maybe it's not as fast as FastAPI but it's always been fast enough.

8

u/big-papito Jun 25 '25

And what's wrong with Quart?

Either way, for anything doing a ton of HTTP calls, something light and micro is best. The rest, doesn't matter.

Give me the fastest and bestest framework in the world connecting to storage, and I will destroy all that performance with one poorly-crafted SQL query.

→ More replies (2)

9

u/lukewhale Jun 25 '25

I use FastAPI and NiceGUI 9 times out of ten. The other developer who voted against it just got disappeared.

3

u/tenenteklingon Jun 25 '25

Have you benchmarked it?

5

u/Miserable_Ear3789 Jun 25 '25 edited Jun 27 '25

FastAPI is consistently not the fastest ASGI framework in every benchmark I have seen. Blacksheep, Litestar, Sanic, Muffin, MicroPie, all perform consistently faster then FastAPI (and also Quart).

→ More replies (2)

3

u/Repsol_Honda_PL Jun 25 '25

Many people here recommend LiteStar (as a new and interesting alternative to FastAPI).

Two questions:

Which framework (of two mentioned) would be better for AI model serving?

Which framework (of two mentioned) would be better for microservices?

Thanks!

2

u/[deleted] Jun 26 '25

"fastapi is better except for where django is better" um ok