DEV Community

Emmanuel Obogbaimhe
Emmanuel Obogbaimhe

Posted on

Django or Flask

Which do you prefer and why.

Top comments (4)

Collapse
 
aspittel profile image
Ali Spittel

I think the use cases for them are pretty different, but both are great!
If you are building something minimalistic or without a database, Flask is much easier to get up and running. If you are doing anything larger with complex database relationships, auth, or want the admin interface -- Django does each so gracefully.

Collapse
 
radorado profile image
Radoslav Georgiev

Both Django & Flask are great and both can do the job for you.

From my experience, I've found that:

  • If you start adding some abstraction in Flask for the common tasks & things, that you do in almost every web app, you are going to end up with Django
  • If you start removing a lot of the features in Django, you are going to end up with Flask

Flask is minimalist framework & Django is not a "fat framework".

For me, learning Django has long term benefits, because the abstraction is great & the libraries for things like "Rest APIs" are also great. It's more suitable for large projects that will scale with time.

On the other hand, I find Flask to be the right tool when I want to expose some kind of Python on the web (with AWS Lambda for example). Then the 1 file approach works great for me.

And if you like the minimalist approach & you like building your own abstraction & using different tools for the job, Flask will be just as great as Django, but perhaps it's going to require more time & investment on your side.

And on the high level, for me, that's pretty much it 👍

Collapse
 
emmanuelobo profile image
Emmanuel Obogbaimhe

That pretty much answers it. I always knew that Flask was he lightweight framework while Django was batteries included but that was very detailed. Thanks.

Collapse
 
stegnerd profile image
Dalton Stegner

For a beginner like me I tried to do sample projects with both flask and django. For me I liked flask more because it allowed me to build up the parts to learn about the interactions. For example implementing databases with sqlalchemy. Django had too much automagic going on to really understand why it was the way it was. Hope this helps other beginners!