Choosing the Right Python Web Framework: Django, Flask, TurboGears, and More
This article surveys popular Python web frameworks—Django, TurboGears, web2py, Flask, Bottle and others—explaining their histories, architectures, strengths, and weaknesses to help developers select the most suitable framework for their project requirements.
Today there are many Python frameworks that make creating web applications easier by organizing modules and handling low‑level details such as sockets and protocols.
Python was created in the late 1980s by Guido van Rossum at the Centrum Wiskunde & Informatica in Amsterdam. Van Rossum later became the community’s "Benevolent Dictator For Life".
After a modest start, Python has become one of the most popular server‑side languages on the Internet; according to W3Techs it powers a large share of high‑traffic sites, surpassing ColdFusion, PHP and ASP.NET. Over 98% of sites still run Python 2.x, with just over 1% on Python 3.x.
Why Frameworks Simplify Development
Frameworks integrate various modules, allowing developers to build applications faster without worrying about low‑level details. This series’ first part introduces the most popular Python frameworks. Modern web frameworks run on the server, though some (e.g., Skulpt, Trinket) can also run client‑side code.
Python frameworks are generally classified as full‑stack or micro (non‑full‑stack). Full‑stack frameworks cover everything from the user interface to the database, while micro‑frameworks are lightweight and focus on core functionality.
Django
Django is a representative open‑source Python framework that follows the MVC (actually MTV) pattern. It was created in 2003 by Adrian Holovaty and Simon Willison at the Lawrence Journal‑World newspaper. Django includes a built‑in template engine, supports Jinja2, and offers regex‑based URL routing.
Its advantages include a single‑package installation, extensive and well‑maintained documentation, a robust plugin ecosystem, and a strong community.
TurboGears
TurboGears builds on established projects such as SQLAlchemy, WebOb, Repoze, and Genshi, and also adopts the MVC architecture. It offers a "minimal mode" that functions as a micro‑framework.
Developed by Kevin Dangoor in 2005, TurboGears migrated to Python 3 in 2013. Its strengths are aggregation support, a powerful ORM, multi‑database transaction handling, reusable code snippets, flexibility for non‑standard components, sharding support, and a designer‑friendly templating system.
Drawbacks include relatively basic admin features, few third‑party extensions, limited documentation, and complexity due to its highly flexible component mix.
web2py
web2py is an open‑source framework that enables rapid development of dynamic, interactive websites. It aims to eliminate repetitive programming tasks and follows the MVC pattern.
Created by Massimo Di Pierro in 2007 (originally named Enterprise Web Framework), web2py powers applications such as Movuca CMS, NoobMusic, LinkFindr, and Instant Press. It has won the Bossie Award (2011) and InfoWorld’s annual technology award (2012).
Key advantages are ease of use—no external dependencies, simple installation, an integrated web‑based IDE, built‑in database, and a powerful API—as well as strong security features like XSS protection, CSRF mitigation, server‑side session storage, and hashed passwords.
Some disadvantages are a less intuitive admin interface, limited permission management, and lack of built‑in unit‑test support.
Flask
Flask is a micro‑framework based on Jinja2 and Werkzeug, released under a BSD‑style license. Notable sites built with Flask include LinkedIn and Pinterest.
Built‑in unit‑test support
Jinja2 templating
Extensive documentation
Secure cookies for client sessions
Development server and debugger
RESTful request handling
WSGI 1.0 compatibility
Unicode support
Large ecosystem of extensions
Flask’s philosophy is to impose minimal restrictions, allowing developers to choose their own ORM, template engine, session middleware, and other components. It is well‑suited for experienced developers and for building simple REST APIs.
Bottle
Bottle is a WSGI micro‑framework that requires only the Python standard library. Written by Marcel Hellkamp in 2009, it provides a minimal set of tools including a template engine, routing, and a WSGI abstraction layer.
Built‑in fast template engine with support for Jinja2, Mako, and Cheetah
Utilities for handling uploads, cookies, form data, headers, and metadata
Built‑in HTTP development server supporting fapws3, Google App Engine, and CherryPyPaste
Dynamic URL support
Its small footprint makes Bottle ideal for embedding in larger applications where low overhead and minimal dependencies are important.
Other Frameworks
Beyond the major players, there are dozens of additional Python frameworks such as Pyramid, web.py, Bobo, Albatross, and CherryPy.
Choosing the Right Framework
The optimal framework depends on project size, communication needs, whether the application is standalone, customization level, overhead, and personal workflow preferences. Reviewing and testing the latest versions of candidate frameworks is recommended before committing to one.
Source: Open Source China www.oschina.net/translate/an-introduction-to-python-frameworks
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
