(Sponsors) Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!
Top 5 Python frameworks for web development
Updated on Jan 07, 2020
It’s no secret that our team loves Python. We’re closely acquainted with this powerful programming language, and use it to solve problems and build software every day.
When you’re constantly moving from project to project, and developing new products from scratch on a regular basis, frameworks become very handy. For the busy software developer, frameworks are a blessing.
Why? Instead of writing the same hundreds of lines of code for every project, programmers can use ready-made components in the framework. This obviously saves time and money, but even more importantly it significantly reduces time-to-market.
But developers have varying needs, and not all frameworks scratch the same itch. That’s why in this article we’re taking a close look at five of our, and the web’s, favorite Python frameworks:
We’ll tell you exactly what they are, show you what type of software each framework is best for, and showcase what various entrepreneurs and programmers are saying online about these technologies.
Django - the best web framework of them all? #
There will probably never be a single framework that is easy to use, and satisfies all of the possible needs and requirements that web developers have. But Django comes very close to that title.
Python is generally a very beginner-friendly programming language, and more people use it than any other general-purpose scripting language. Even if they use it for academic purposes, or machine learning experiments, Django enables people who know Python to transition to building web applications quite quickly.
This framework provides a whole lot of goodies in a single package. It was released in 2005, so it’s a mature technology with a lot of community support.
The main tagline of Django is that it gives developers everything they need to build large web applications that can perform lots of complex data operations very quickly.
Apart from all components necessary to set-up and run a functioning web application, the Django package comes with particularly interesting extras. It offers a scalable user authentication system. There are also protection mechanisms against the most common types of cyber attacks.
And, one of the things that developers like the most about Django, it comes with a quick-to-setup admin panel that can be used by programmers to easily manage content in their application.
What software is Django best for? #
One of the main complaints with Django is that it has the sort of convention-over-configuration approach that’s very similar to Ruby on Rails.
It means that the creators of Django assumed the best way to do things, and built the framework around it. Which is great, as long as you don’t want to do something that goes beyond, or against, the standard Django way.
This framework is a complete package that enables you to build a whole web application without using any other tools, but it isn’t easy to customize. Which makes Django great for common types of applications. On the other hand, it’s not good if your project is unconventional from the get-go.
Django is used in products such as:
- Instagram - social network and photo-sharing
- Pinterest - social bookmarking site
- MIT - website for one of the world’s leading technological colleges
- Udemy and Coursera - worldwide providers of digital courses on any topic
- Disqus - comment plugin for blogs
- Zapier - SaaS for automation powered by easily connecting various web services
- Pitchfork - leading site for independent music
- Teespring - selling customizable clothes and accessories
- Aspire - team perk management
This tell us that Django is great for web applications that have:
- Huge traffic
- Lots of content (especially user-generated)
- Connections and integrations with multiple web services
All in all, Django by itself won’t enable you to build the next big web innovation. But it will give you all that you need to build and manage a standard type of web application.
What do people online say about Django?
- Even after the Facebook acquisition, Instagram changed their database server but didn’t let go of Django, which goes to show just how scalable it is, and that it can handle any amount of web traffic
- It’s an amazing package that gives you all that you need, and provides an easy way to remove things you don’t need With Django, you can achieve anything, albeit only to a certain degree due to its’ monolithic structure
- Django is SEO-responsive, with URLs that can be read by humans, which can contribute to a better page ranking
- As products scale, the need for customization grows, but Django is so well-built that often companies rely on original Django code for years on end
- Django is fast, simple, secure, stable, fitting for any web project, and the code is reusable
Our next framework is considerably different from Django. It’s much smaller, as it’s actually a micro-framework. It provides the bare minimum of things needed to start building a web application, enabling developers to customize all that comes on top of this foundation.
Flask is based on the approach that programmers want to learn things as they go. If they don’t need certain features, they won’t need to dig through the documentation to understand how they work, or how to turn them off — which is what they would need to do with Django.
Theoretically, it allows developers to save some time. In practice they will spend that time expanding their fundamental Flask web app, but they can do so in any way they want. So the biggest advantage of Flask is customizability.
What software is Flask best for? #
This framework is for development teams that have their own way to do things, and want to save time by using ready-made parts for the back-end of their software. Sort of like putting a working engine into an empty car frame, and then building the rest of the car on top.
Flask is used in products such as:
- Close.io - SaaS for customer relationship management
- Mailgun - APIs for emailing
- Zillow - real estate database
- Lyft - ridesharing app
- Reddit - one of the largest social sites online
- Netflix - everybody’s favorite app for binge-watching tv series
- Qordoba - virtual content assistant for large writing teams
- Domino! - mobile real-time multiplayer dominoes game
- Uploadcare - content delivery network as a service
- Teleport - city-comparison service for relocating workers
- Runscope - API-monitoring solution
If you look closely, you’ll see the main difference between projects that use Django, and projects that use Flask.
Products with Flask are nimble, different from their competitors, unconventional, and often provide innovative services, or traditional services in an innovative way.
It’s worth mentioning that some companies use both Flask and Django, like MIT. This means that these technologies aren’t mutually exclusive, and can be used in tandem to provide different services to users of your web application.
What do people online say about Flask? #
- Flask is one of the best tools for API-based, serverless products
- It’s a light framework for fast development of REST APIs, with built-in support for scaling the API to accommodate high traffic
- Flask is straightforward, and enables even less-experienced developers to build prototypes quickly
- It allows developers to do what they need, in any way they want, there are no limitations regarding the architecture of the application
While Django and Flask are multi-purpose, Tornado is built to support a very specific type of web application. It is asynchronous, built to handle huge numbers of open connections at once, and to stay connected to users for long periods of time.
Typically, users send a request to the server, and then the server responds by providing the data and content that the user requested. Think of Wikipedia. But this type of architecture is too slow for real-time web apps like Facebook, which require the user and the server to stay connected all the time.
This makes Tornado great for real-time applications that need to handle huge amounts of data requests - like the newsfeed on Twitter, or real-time chat applications.
Within the Tornado package there are also fundamental tools that users have come to expect from social networking sites, including security measures, cookie management and support for third-party logins (to let users log in through FB or Gmail).
What software is Tornado best for? #
Tornado was built with a specific purpose in mind, which is essentially to enable real-time features, like social networking and newsfeeds, at a low cost and with as little trouble as possible.
Tornado is used in products such as:
- Zalando - leading online fashion platform
- Keen.io - set of APIs for monitoring in-application user behaviour
- Lensley - photobooths connected to an e-commerce platform
- Indico - automation of documentation-related processes
There are also companies that use Tornado in combination with other frameworks. Uploadcare uses it alongside Flask. Yet again, this shows that Python web frameworks can be combined to squeeze the best features out of each of them, in order to provide a better user experience.
Overall, Tornado’s main use is clear. It is mainly used to provide real-time features in web applications.
What do people online say about Tornado? #
It doesn’t complicate things that should be easy, so you can build simple features faster, with less setup and less lines of code Tornado shouldn’t be used in computation-intensive applications, but you can still use it for networking, while transferring computational tasks to a different service Tornado is excellent for microservices
Web2py is an alternative to Django, but with few differences in the features and - unfortunately - worse documentation, and a smaller community. This framework comes with everything that’s necessary to build a web application, and it does certain things in a unique way.
It is a preference framework, meaning that some developers like it for it’s quirks, but ultimately it serves the same purpose as Django, and most programmers will choose the latter.
But there are a few things that make Web2py special. For one thing, it is focused on backwards compatibility. The features that come with Web2py are great for connecting a single database to multiple web applications without lagging, as well as handling many databases by one application.
What software is Web2py best for? #
Major start-up projects with funding won’t go for Web2py. This framework is for special applications, where some of its unique features can really go into play. In particular, it can be great for applications that need to connect with multiple databases without latency.
In most other cases, you’ll be better off choosing Django.
What do people online say about Web2py? #
Web2py becomes too difficult to handle when the complexity of the web application increases This framework is not suited for junior programmers It can be difficult to make Web2py communicate with other services through API
As the name suggests, Bottle is basically an alternative to Flask — it is even more simple than Flask, but that’s because it has a clear purpose.
Bottle is great for small and reliable web applications. What’s interesting is that the whole framework is a single file, and that file contains everything you need to establish a simple web application. But that’s also where Bottle’s main limitation comes from. It’s hard to build applications larger than 1000 lines of code, which is very little.
It’s all about speed and simplicity on a small scale. It’s included in the basic Python library, so there’s no need to install anything to access it.
What software is Bottle best for? #
Bottle is only great for small applications. It’s also good for fast prototyping, but the end application will have to be built using another tool if it’s going to grow.
What do people online say about Bottle? #
- The documentation is great, Bottle is easy to integrate with other libraries, and it’s great for making restful APIs with small memory consumption
- It is highly recommended for Python programmers that want to create an API, or prototype a new service very quickly
- Bottle is simple and light, and it enables developers to build prototypes quickly and without the ‘heaviness’ of Django, but it’s not built to grow into a full-blown system
From micro-frameworks to huge frameworks, Python has it all #
By all means this isn’t an exhaustive list of Python web development frameworks. There are a lot more of them out there, and nowadays many programmers build their own frameworks to suit the unique needs of their projects.
This goes to show that the Python environment is very rich, and provides tools for any situation. We chose the above 5 frameworks for their proven usability and the community surrounding them.
When it comes to web development frameworks, Django and Flask are by far the most popular, with the most rich ecosystems of developers who use it. Tornado, Web2py, and Bottle don’t have that, because they are niche-purpose frameworks that are taking longer to grow in popularity. However, they have proper documentation which should help developers overcome issues.
Ultimately, there’s a Python framework for any type of web application. Additionally, Python frameworks can work in tandem with other technologies, enabling development teams to create complex products that combine the best features of multiple technologies.
But in the end, the project matters the most. Choosing the right framework shouldn’t be based on which one is more popular. Rather, it’s a matter of picking the framework that contains exactly what the development team needs to build a product that perfectly meets project requirements.
Other Tutorials (Sponsors)
This site generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!