5 ms·
How do people feel about Django vs flask in 2023? Just trying to farm for other's experiences because I find flask easier to start off with but I suspect I am b
by nine_zeros 3y ago
How do people feel about Django vs flask in 2023? Just trying to farm for other's experiences because I find flask easier to start off with but I suspect I am biased.
- Daishiman 3y agoEvery sufficiently large Flask app reimplements half of Django, badly. I’m the sole maintainer of a Flask app that uses SqlAlchemy, and the experience is similar except that I really miss the admin and auth. However every single flask app ends up using slightly different libraries and architecture, which means that onboarding always takes longer than an equivalent Django app. Also, I have over a decade of Python experience; I wouldn’t count on people with little Python experience to produce well architected apps in Flask, whereas Django does a lot of guiding the user towards established patterns. Some parts of Django are antiquated and I do not recommend them (specifically the Forms API really has been superseded by pretty much any newer forms library), but that’s still way less baggage than having to pick up a new stack for every new Flask app.
- canadiantim 3y agoCurious why you think Django Forms API has been superseded? Are you recommending people use something like WTForms directly?
- Daishiman 3y agoWhen I started using Rest Framework as I had more need for API endpoints than HTML pages I realized the Serializer API was way easier and more intuitive and pulled more weight. Then I began using Pydantic and its API design does pretty much the same except for the rendering part. I think the rendering aspect in the Forms API has always been a PITA and the validation aspects always left something to be desired. Rendering and validation/serialization should be decoupled IMO, and in that sense the Forms API fails. Sometimes I wish for the Django admin to be reimplemented in FastAPI/SqlAlchemy as a more modern approach to the same problems.
- smashed 3y agoThis article is a few years old but it compares both really well: https://adamj.eu/tech/2019/04/03/django-versus-flask-with-single-file-applications/ https://adamj.eu/tech/2019/04/03/django-versus-flask-with-si... Flask works for simple projects but as your needs grow, the built-in and extensive Django ecosystem will have you covered. And as seen above, Django in its simplest form is no more complex. Some people really don't like the Django ORM, so in this case you might avoid Django altogether. It's possible to use Django without its data layer but it's a big part of its value. Also if you are building a pure API project, FastAPI is worth checking out for a streamlined process. Django Rest Framework works too, but is an extension.
- robervin 3y agoI do think leaning on the Django ORM for so many years has hurt my ability to write SQL on its own, but it's just about the only ORM thats ever clicked for me in that way.
- fbdab103 3y agoDue to $WORK factors, I have to write Flask, and I hate every second of it. So many things which come for free from Django require a partially supported plugin with so-so documentation. Could Django do some things better? Sure, but it gets so much right, and has so much community support, it should be the default answer. If you ever get stuck with a problem, thousands of others have faced the same thing. With Flask, owing to your special snowflake configuration of extensions and wiring, you may not find any guidance anywhere.