March 10, 2020   |   4min read

Flask vs. Django—Choosing the Best Framework for Web Development

Python is currently the second most popular coding language in the world. No surprise then, that according to the 2019 report by Jetbrains, Django and Flask are by far the two most used Python web frameworks. Both open sourced and supported by the community, they are a perfect example of how much value sharing knowledge, and #CodeLeadership can add to the tech industry. If you’re wondering which framework is going to be better for your web project and developers, here’s a little cheat sheet.

What is Flask?

Flask is a microframework in Python used for developing small or medium web apps. Since it’s a microframework, it doesn’t require any particular tools or libraries. Flask was created by Armin Ronacher, an Austrian open-source software programmer. According to him, the idea for Flask was originally an April Fool’s joke (hence the data of creation—1st of April 2010). With almost 50k stars on Github, Flask was definitely an unexpected success.

What is Django?

Django is a full-stack framework for web app development, owned by the Django Software Foundation since 2008. Open-sourced and written for Python, its goal is to ease the creation of complex, database-driven websites. Currently Django has more than 47k stars on GitHub and counting.


Flask—all you need to know

  • Flask has a route decorator, which is used to bind URL to a function, making application URLs easier to remember for a user.
  • In Flask you can write a code in Python in any way you wish, which gives the developers more freedom…and more work.
  • No admin panel in Flask (making your work potentially slower and more complex—then again, you can customize your framework as much as you like).
  • Flask can prove to be perfect for smaller projects with a less complicated structure. For example, when your app has only five endpoints and doesn’t use any database.
  • You have an ability to use full Python, aka customize your app’s structure.
  • On the other hand, Flask might be complicated to use for beginners. However, when it comes to learning the framework’s architecture Flask is way easier than huge Django.
  • If you’re inexperienced, security might be an issue since you have to manage security on your own. Big frameworks like Django, have basic security features built-in.
  • Even though it might be unfair to compare a microframework like Flask to a full-blown framework like Django—Flask is definitely faster, for obvious reasons.
  • Even though Django has an ORM it works only with relational databases. With Flask you can use both relational and non-relational databases, but it doesn’t offer a built-in ORM.
  • You can always move an app from Flask to Django, if your project becomes too big and needs some features that Django offers.
  • Flask is perfect when your product relies on a microservice architecture (instead of writing one monolith, you write many little projects that do one specific thing and communicate with each other via API).

Django—all you need to know

  • Django imposes a certain design pattern: a model view template, where you have to define separately so-called models (objects that represent your data).
  • The framework provides support for communicating with databases, including a built-in object-relational mapping layer (ORM) that can be used to interact with relational databases such as PostgreSQL or MySQL. However, Django doesn’t work well with noSQL (non-relational) databases.
  • Django offers a different, more “template” way of writing an app. It has a built-in Admin panel (Django’s “CMS”). It also has its own templating language based on Jinja. Some even say that in Django you don’t write in Python, you write in Django.
  • Django might not be the right choice for small apps—it’s a heavy framework with a lot of features. This is why Django is usually used for bigger, more complex projects. However, once you get familiar with the complex structure of Django, writing a simple app can be very fast and easy.
  • The framework speeds up the development process in apps with complicated structures that use databases.
  • It’s easier to write apps in Django for beginner developers than in Flask, as there are a lot of tutorials, and examples.
  • Django is very secure—it has built-in security tools, so there’s no need to write them on your own.
  • For some developers, Django can have even too many features since usually, they don’t use most of them. Luckily, you can configure the framework and turn off the features you don’t need.
  • It imposes the structure and model view template—if your app needs another structure, then it will be quite hard to build it in Django.
  • Django—unlike Flask—is perfect for monolith services.


Final thoughts

Even though Django seems to have it all, it might turn out that you only need a small part of the tools it offers—in which case it’s worth considering Flask that gives you more development freedom and is faster. Having said that, all depends on your development skills and project’s needs. For instance, if I have a project that involves a relational database, then I’d go for Django (where a database support is built-in). If, however, my app has only a few end-points, a simple enough structure, or a non relational database, then I’d go with Flask.

Django was designed to simplify your work, but, as it always goes with simplifications, it works in 85% of the cases. For the rest of the projects it might probably be better to use Flask. If you have any doubts or questions about Flask or Django, don’t hesitate to contact us!

Dariusz Aniszewski

Lead Software Engineer

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!