Disadvantages of Flask
Flask is a micro-framework written in python. Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine. It is called a micro framework because it does not require tools or libraries. Flask supports various extensions that can add additional functionalities. Few applications that use flask are
- Community web page of the flask
Disadvantages of flask
Some of the major disadvantages of the flask framework are,
- Not suitable for big applications.
- Full-Stack experience.
- No admin site.
- No login or authentication.
- Migrations can be difficult.
These disadvantages are based on comparing flask with Django. Django is heavy-weight, whereas, with Flask, you have to build everything on your own.
Not suitable for big applications
when you have a big project, using Flask could be time-consuming. It is suitable only for small-scale applications. If you have a simple, innovative use case to be added to an existing application, Flask should be your choice as it offers flexibility.
Each project can be a single application, however, multiple models and views can be added to the single application. Whereas Django allows users to divide a single project into multiple small applications which makes them easy to develop and maintain.
The flask community is not as big as Django. so, finding a solution to a problem is difficult as there won’t be many active users to answer the questions.
Django has been around since 2005; Flask kept its foot in 2010 — about 5 years later. At the time of editing this article, Django has 244615 questions on StackOverflow whereas the flask has 40800 questions.
Django has a default web template engine that provides a full-stack experience. Flask does not have a default template engine. It uses the Jinja2 template engine for this purpose. It comes freeloaded with flask. So there is no need to install it separately.
No admin site
One of the main advantages of Django is the availability of the admin site. Here we can see all our models, insert new records, update and delete old records. Whereas in flask we cant do that. There is no admin site. But don’t worry there is a workaround. Installing a library called flask-admin helps us to overcome this problem by creating an admin site for us.
The admin site enables us to create/view/edit and delete records from the database. We can also customize this admin site to add filters, search fields, and sorting to the database records.
Django admin site
This is how the Django admin site looks like. My database has a table called a book. I can view/edit/delete/add records to my table right from here. The admin site is one of the things I most like about Django. This prevents us to access our records and perform operations on them without having to write lines and lines of queries.
No login or authentication
Flask does not provide authentication. There is no login functionality. But Django provides us login and authentication that can be used in our web application for login purposes.
Django has inbuilt functionality for login mechanisms. We can use the default User table from Django to create users, set passwords, and much more.
ORM is the next major thing required for any web application. ORM provides the API to perform CRUD operations on the database. Without ORM we have to manually write SQL queries to perform CRUD operations. This can also be fixed by installing another library called SQLAlchemy.
By default Django supports ORM. Let us say I have a table called student. If I want to get all the records from the student table, I can simply do something like this in Django.
This will give me all the records from the student table. This is equivalent to the following query in SQL.
SELECT * FROM student;
Since this is a simple query it will not make a big change. But you get the idea right? Complex queries can be easily written using ORM. Of course, flask lacks this feature too.
ORM in Django
Migrations can be difficult
Migrations are also difficult in Flask. Unlike Django, there is no direct way to migrate the database. This can be fixed by installing the Flask-migrate library.
In conclusion, Flask is not actually that bad. All the features of Django can be obtained here with some additional work. The only disadvantage is that there is no direct way to access some of the best features of Django.
Hope this article is helpful. Happy coding!