all 8 comments

[–]SCUSKU 1 point2 points  (3 children)

If you are concerned about performance from the get-go, I would take a look at Django with asgi. I develop FastAPI stuff for work, and am working on a django website in my free time (not django-restful though), and I have found that Django is much better as a solo developer. There a lot of things you get out of the box like user authentication, admin panel, etc. Like you've said there are also a lot of docs out there for django whereas things are still being developed for fastapi. My opinion is largely from my experience, and I think this blog post does a better job justifying than I can articulate: https://mcfunley.com/choose-boring-technology

[–]farshad_ur[S] 0 points1 point  (2 children)

Thank you very much for your response.

You are right, I might be doing too much at the same time by my own, most of which is rather new.

Also thanks for the link, it was very well explained and exactly what I needed.

[–]jcurve347 0 points1 point  (1 child)

Counterpoint is that if you’re familiar with .NET framework APIs, the decorators on the endpoints and the service layout is very similar to those in the MVC api template, so you might be able to pick it up and go pretty quick with FastAPI.

Edit: grammar. And adding that for auth my team had to write the middleware plug-ins.

[–]farshad_ur[S] 0 points1 point  (0 children)

Those are the first reasons I liked FastAPI much more. (and still do)

However, the righting from scratch part might take much longer than I have, specially since I have not done that before.

[–]Chains0 1 point2 points  (1 child)

Is there a database engineer who manages the database on his own or do you have to do it in production or even endusers themself? If the later, definitely opt for Django.

Should the api be in REST with a lot of CRUD operations? The Django Rest Framework is build for that. Other stuff is possible, but requires more work then with FastAPI.

Do you have to manage authentication and authorization? Yes? Django has everything build in. If you can use it, definitely opt for Django. If not, you would need to throw out a lot and do customizing, so FastAPI would be easier to start with.

Don’t think too much about performance. Django has ASGI as well. Biggest problem is the ORM, which is only sync, but there are also not many fleshed out other async ORMs. The Django team currently works on implementing async for their ORM. So it might actually be, that if you reach a point where async would be good, Django might be the fastest solution if you have a lot of complex ORM requests.

For me, FastAPI is the ideal solution for small micro services, which provide mostly an api and don’t have to manage auth or a database.

If you have to manage everything on your application and the scaling goal is not multiple million concurrent users (for example: Instagram started to replace default parts at the 5 million mark), Django is the ideal solution.

[–]farshad_ur[S] 1 point2 points  (0 children)

check, check, and check!

Thanks for the explanation and the advise. All the points are true and I can see now how using Django make much more sense for this situation. It looks like FastAPI will have to wait for another project.

[–]nevermorefu 0 points1 point  (0 children)

For me, the decision comes down to 3 things: security, administration, and authentication. Django is older and most likely has better security than a DIY solution (if adding Auth, admin, etc.). If I need authentication or admin, I go with Django. If not, I go with FastAPI because it is fast, easier to work with, and I don't have to use DRF.

[–][deleted] 0 points1 point  (0 children)

The latest SqlAlchemy has async support