Selecting a Python backend framework
I’m spending the next six weeks building a niche SaaS app (a refunds portal for a friend’s e-commerce site). Tomorrow is the first day out of 42. The plan is to build the back-end in Python Flask. But maybe I’m making a mistake by not using Django?
Get Erik Edin’s stories in your inbox
Join Medium for free to get updates from this writer.
I have only worked with Flask myself, so I use the analysis in this article as the reference point. The main benefits of Django versus Flask are:
- Django provides a structure for large applications out of the box. Flask scales reasonably well in my experience. Authentication works reasonably well in with Flask-User or Flask-Login, but they do have some important shortcomings. I’ve also found that the lack of a standard way to build Flask apps can make tutorials harder to follow.
- The admin interface provided by Django seems like a nice benefit. I’ve found working directly in SQL has been alright, and haven’t really missed an admin interface when working with Flask, but maybe it’s slowing me down.
- Templates aren’t very important as I plan to build the front-end in React. The Jinja templating engine used by Flask is also easy to use and powerful enough.
- Django comes with Bootstrapping, which I’m not quite sure how I would benefit from. That could mean I’m missing a trick. This is one to revisit at the end of the project to see if it was important.
- Flask requires that each project is a single application, while Django makes it easier to create several small applications inside a project. Since my project only needs to server a specific use case, I don’t expect this to be a problem. Flask also has “blueprints”, which seem to allow for similar code splitting. At the end of the project, I’ll see if I’ve found this to be good enough or not.
- Django has a strong ORM system. I’ve found that SQLAlchemy with Flask works really well, and haven’t had any issues there.
One thing not mentioned in the article is testing. My experience with pytest for Flask has not been good. Most tutorials assume that a SQLite database is used, while I prefer Postgres. Especially JSON columns have been an issue, since these are not supported by SQLite out of the box. It’s also quite slow. The unittest library is another option I’m trying out now that seems to be faster.
Besides testing, my biggest concern with Flask is that I will eventually hit some limits in the framework that I can’t get around. Maybe Bootstrapping will be very important, or the single app structure isn’t scalable enough.







