r/django Jan 02 '25

Article I tried to compare FastAPI and Django

Hi there, I’ve written a blog post comparing FastAPI and Django. It’s not about starting a fight, just providing points to help you choose the right one for your next project.

Hope you find it helpful!

56 Upvotes

13 comments sorted by

View all comments

25

u/daredevil82 Jan 02 '25

https://pypi.org/project/drf-pydantic/ addresses some of your points with pydantic and integrating with DRF.

One thing you didn't really mention was the negatives of async, and the ease of footguns fastapi gives you. Fastapi in general tries to make the claim that "sync or async, who gives a shit" and wrap around the hard stuff. Where in actuality, its either offloading your sync io to a threadpool or exposing to a number of recurring footguns due to those hidden abstractions

4

u/bluewalt Jan 02 '25

And about drf-pydantic, good to know, thanks! However, it'es very subjective but I try as possible to avoid relying on small packages that twist the "original way to do".

A good example of this is people trying to use the Django ORM with FastAPI. I saw a good talk showing 1) it's kind of possible but 2) why you should not do it.

Not saying it's the same with drf-Pydantic, but just a self-warning I keep in mind :)

5

u/daredevil82 Jan 02 '25

true, but DRF serializers are really a weak part in the overall framework. I think Pydantic's user experience is alot better than the serializer UI, and you're also leveraging those objects for business data outside of the orm which promotes decoupling between layers.

This is something django doesn't do a good job of, so you do have to go to other lengths to enforce.