What are the differences between Flask and Django?

7

I started shortly 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 two.

    
asked by anonymous 23.08.2017 / 09:45

1 answer

10

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

A full-blown framework like django already comes "factory" with all the essential tools for backend development, while a microframework like Flask comes with just the bare minimum needed for development startup and requires plugins for tools on demand .

For developing a web application in python, you usually need to:

  • Template language
  • Session Management
  • Manipulating forms
  • Manipulation of relational databases via ORM
  • User Authentication Services;
  • Setting up and manipulating URLs (Routes)
  • Handling and handling HTTP requests / responses

In a fullstack framework like django, all of these functions come as "built-in" packages, while in a microframework like Flask, you have to plug in plugins for that.

Even among microframeworks there are differences between the choices for these tools, for example while Flask has made a choice for the template engine ( Jinja2 < a>), 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 over microframeworks, it seems obvious, "if the fullstack already comes with all the batteries, why choose a micro?" but this may be a mistake. The two options have their advantages and disadvantages. While in a fullstack you can have the sensation that everything is at hand, in the micro you have the feeling of freedom, however while in the micro you can have the feeling that something is missing, in the full you can have the sensation of being imprisoned .

Now speaking from my personal experience, I had a brief period with Flask and now I'm involved with django and I've already realized a crucial detail that will get me back to Flask on a specific project. To deal with a legacy database, it's much easier with Flask than with Django, depending on your ORMs, although django also supports the same FLask's ORM (SQLAlchemy).

    
23.08.2017 / 11:45