Python Frameworks Comparison
Published: 2021-08-29 05:59:53

Flask

Flask is very performant.

Very flexible and doesn’t require users to use any particular project or code layout.

Flask is simple and its core features are not difficult to learn.

Flask doesn’t come with a built-in ORM framework. Developers can use one of many open source libraries or extensions. Such as Flask-SQLAlchemy, Flask-Pony, etc.

Ships with SQLAlchemy with Master Slave load Balancing.
No built-in admin panel, but you can use the Flask-Admin extension.

Supported via extensions such as Flask-RESTful, Flask-Classful, Flask-RESTPlus.

Despite being a minimalist Framework, Flask does an excellent job of addressing common security concerns like CSRF, XSS, JSON security and more out of the box. 3rd party extensions like Flask-Security can be used for common security measures.

Little built-in protection. Must be handled by developers themselves or by using 3rd party extensions.

Flask uses Jinja2 out of the box.

No built-in support but there is a Flask-WTF extension. For SQLAlchemy support, that is, to create forms based on models, there is WTForms-Alchemy
Only provides support for cookie-based sessions but there are extensions available for authentication, authorization and account management.
Built-in support using Python’s unit test framework.
https://flask.palletsprojects.com/en/1.0.x/quickstart/


— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Django

Not as performance as barebones or even full stack frameworks. Extensions could impact performance adversely.

Django expects things to be done in a certain way unlike microframeworks (e.g. Flask) which have no opinion on how developers structure things. However, It does this without compromising on flexibility.

Has a learning curve especially for those who are not familiar with other web frameworks.

Django ships with a built-in ORM framework for developers to start using out of the box.

NoSQL databases are supported through open source libraries or extensions. To use MongoDB with Flask, Flask-PyMong is a popular choice. CouchDB, Cassandra, and DynamoDB are also supported via libraries.

NoSQL databases are not officially supported by Django. There are open source projects like PynamoDB or Django MongoDB Engine, Django non-rel to support NoSQL.
Django ships with a web-based admin site that has a friendly UI.

While not built-in, REST development is supported via the popular and active Django REST Framework project.
Built-in protection against several common attack vectors like CSRF, XSS, and SQL injection.

Uses its own templating engine.

Ships with built-in ModelForms which provides complete support for web forms including input validation, CSRF, XSS, and SQL injection.

Built-in authentication, authorization, account management and support for sessions.

Built-in support using Python’s unittest framework.
https://www.djangoproject.com/start/


— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
TurboGeaers

Not as performance as barebones or even full stack frameworks. Extensions could impact performance adversely.

Developers can use TurboGears as a microframework which is very flexible. However, as you start building towards a full stack solution, it does expect things to be done in a certain way.

It has a learning, but since it uses many existing 3rd party libraries, it becomes a little easier to onboard.

Supports MongoDB out of the box using Ming ORM. Ming ORM was developed to look like SQLAlchemy so it’s easier for developers familiar with SQLAlchemy to start using it.
Built-in admin panel.

Built-in support using tg.controllers.RestController.
Ships with internally developed Kajiki templating engine, but supports multiple templating engines including Genshi.
TurboGears relies on ToscaWidgets2 for building and validating forms.

Ships with repoze.who which is an authentication and identity framework for WSGI applications.
Using Nose.

https://turbogears.readthedocs.io/en/tg2.3.12/


— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

A developer already experienced with Django or Flask can take any other framework easily. Turbogears are mostly used for full stack application development. However, any framework can be used as a back-end framework easily, removing the templating part and using REST framework.