Over the 16 years that this blog spans I must have, at some point, mentioned that I believe sometimes we get knowledge when we’re not ready to receive it.This isn’t some spiritual or new age thing (although you’ll hear Chopra and/or Tony Robbins talk about the phenomenon). It’s simply my lived experience. Sometimes you come across some knowledge, but there’s some underpinning knowledge missing or maybe some life experience you don’t yet have to put your new knowledge into context. So sometimes this leads to a difficulty in learning the concept and other times you just don’t get the point of it and file it away or throw it away – no need to waste neurons on this!
Then, for some reason – I think I was flipping through my Python books – I decided to look at one of the Django books and found that Django comes with an admin interface built-in. And making changes to the admin pages are somewhat trivial. I was rejuvenated in my desire to help my colleague. So I started recreating the site with Django. There is indeed still a higher cognitive load to Django. The simplest Flask site with its app.route is still infinitely simpler than Django with its views, models, forms, settings, etc. And yet, if you’re already going to go for a more complex site and do your user interface in Python, suddenly all that complexity pays off. The ability to set up your models and forms with ease makes a model-heavy workload so much easier. And I had a better understanding of what all this meant now that I’d work on Flask.
What I find most interesting, and what led me to write this post, is that I recently got O’Reilly’s Flask Web Development from another Humble Bundle. Just as having worked on Flask helped me better understand what Django is trying to do, having worked on Django is feeding back into helping understand Flask. Having worked with models and forms in Django has cemented in my head how web backends (particularly if written in Python) are thinking about the web and separation of concerns; it’s all forming this virtuous cycle. And so while I anticipate perhaps having some momentary screwups where I try to think Flask-y while working Django or Django-y while working on a Flask site, each is helping me become a better Python web developer no matter the framework being used.
The important thing is not to be dogmatic about things. There are occasions where each is best. I LOVE FastAPI for my Civilization VI Play By “Email” webhook server. As I spent lots of digital “ink” above describing, Django works perfectly for my colleague’s web app. Using Django freed me from coding and maintaining all the admin code and database handling. And on the other side, my webhook server just needed to have some REST API points. Even if I eventually add database support, I still don’t need any kind of admin or real user account service with that app. So when you’re ready to write your next Python web app, think about your needs and think about what the strengths and weaknesses of all the frameworks are.