What are the differences between Flask and Django?

Asked

Viewed 2,502 times

8

I recently started in the Python language and am currently working on a project using Flask, MariaDB and WebSockets.

I see people talk a lot about Django and would like to know the differences between.

1 answer

15


For those who are already working with a framework, it is relatively easy to understand, Flask is a micro-framework while Django is a Fullstack framework.

A Fullstack framework like Django already comes "from the factory" with all the essential tools for backend development, while a micro-framework such as Flask comes with only the minimum required for initial development and requires plugins for the tools on demand.

For development of a Python web application, it is usually necessary:

  • Template language
  • Session management
  • Form manipulation
  • Manipulation of relational databases via ORM
  • Authentication services for users;
  • Configuration and manipulation of Urls (Routes)
  • Handling and handling of HTTP requests/replies

In a Fullstack framework like Django, all these functions come "embedded" as packages, while in a microframework like Flask, you need to go connecting plugins for this.

Even among micro-frameworks there are differences between the choices for these tools, for example while Flask chose the Jinja2 for the template mechanism, the Bottle has its own "built-in" mechanism, but supports Mako, jinja2 and Cheetah.

Which is better?

None! : -) In the mainstream there is a clear tendency to value the Fullstack framework more than the micro-frameworks, it seems obvious, "if Fullstack already comes with all the batteries, why choose a micro?" but this can be a mistake. Both options have their advantages and disadvantages. While in a Fullstack you can have the feeling that everything is at hand, in the micro you have the feeling of freedom, but while in the micro you can have the feeling that something is missing, in the full you can have the feeling of being trapped.

Now speaking of my personal experience, I had a brief period with Flask and now I’m involved with Django and I’ve already noticed a crucial detail that will make me go back to Flask on a specific project. To handle legacy databases, it’s much easier with Flask than with Django because of its Orms, although Django also supports the same ORM (Sqlalchemy) flask.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.