Should you learn Flask or Django?

Should you learn Flask or Django?

2016, Jan 07    

Flask just seemed a lot more straightforward to me. There was no ā€œmagicā€, just a small API to learn. Djangoā€™s community is very strong, particularly on IRC. There is no forum that Iā€™ve found that is popular for them, though, which I found a little odd. Flaskā€¦ well, there isnā€™t much to Flask. There is a Werkzeug community and a Jinja2 community, and Iā€™ve found lots of information I needed via search for both of those. Iā€™ve not tried to find them on IRC, as Iā€™m at work and it is blocked.

/r/django is far more active that /r/flask, though.

The thing is, with Flask, Iā€™ve not needed the support. The documentation is very good, and itā€™s so small there really isnā€™t a lot to go wrong. Iā€™m learning different pieces of the framework as I develop more advanced needs, and they stay out of the way until then. With Django, I often found myself having to learn why things were structured the way there were, before I could learn the system. An example of this would be forms processing - on Django, I remember having to learn about the Forms models, and all of their configuration. Then I had to learn about Forms validation, and how they were handled in the view (by branching the logic based on request type). Finally, I had to learn about how to tie a form to a Model, or to use a ModelForm.

With Flaskā€¦ there is no forms processing included to my knowledge. I built the form in HTML (and wrote some helper functions in the process), validated the data on an ad-hoc basis, then wrote the SQL to drop it in the DB. There are extensions that add form processing to Flask, but I didnā€™t use them.

In this use case, a competent Django developer could get a CRUD form up and running in a shorter time than a competent Flask developer - but by the time I would consider myself ā€œcompetentā€, I will have developed my own library of helpers functions and architectural conventions, and will have learned a lot about Python in the process. It isnā€™t really a fair comparison

  • no one sits down with only one module and writes everything else from scratch.

I think Iā€™ll ultimately end up using Django for complex application development, and Flask (or its components, Werkzeug and Jinja2) for writing things that are less well-defined or donā€™t quite fit into the mold poured by Django. I donā€™t think itā€™s fair to say that one is better than the other overall, but I stand behind my contention that Flask is better suited to a new Python programmer.

But definitevly, Iā€™m in love with Django :)

Anyway, a rule of thumb could be:

If you donā€™t need:

  • django-admin
  • django ORM
  • form / modelform facilities

or youā€™re a newbie web-developer, then flask is you choice. But, for everything else..

come on, weā€™re djangonaut my friend, trust your soul ^^