Flask vs. Django vs. Pyramid vs. Plone
April 29, 2013
In my two years @seantis I had the chance to work on web applications ranging from the small and benign to the big and bulky. For these applications I used (and cursed at) a number of web-frameworks:
I know there’s no shortage of blog posts comparing Python web-framworks, but I developed a certain view on these four frameworks which might be interesting to newcomers.
A Question of Scope
All these frameworks are in active development and they are all - in their own way - excellent tools for writing web apps using Python. What’s really different is the size or type of project they perform best at.
So this is really about when to choose which.
Flask is a one-file microframework. It’s what I used for my first Python web project (a minecraft server status page) and incidentally for my most recent project a webcron.org kiosk-style monitor.
I find the strenghts of Flask to be the sheer simplicity of creating a one-site Python web app. It also kept my head free of more complex conecpts when I started out.
You should therefore choose Flask to learn, or if your app is not going to be more than a one-page thing. There’s some room to grow a Flask project into a more serious app, but I would certainly not recommend going too far with it. You’ll just end up reinventing the wheel.
Django is probably the most famous Python webframework and rightly so. Django is easy to get started with, thanks to a documentation focused on beginners. Django comes with a lot of integrated functionality, which means you have to think less about structure and organization - just follow the rules. I used Django on a medical questionnaire app. Its builtin admin and user management facilities were a real good fit for the project.
I find Django to be a perfect for CRUD apps which do not feature much out of the ordinary. Thanks to its structure and high level of integration you end up writing more actual application and less facility around it.
Unfortunately, this model breaks down a bit once you want to use other python packages which do a Django thing better. It’s for example possible to use SQLAlchemy instead of the Django ORM, but it’s certainly not straightforward. As well integrated as the Django parts are, they don’t make it easy to mix and match different packages from the Python community.
Pyramid is what you want if you are doing a “serious” web application. You can of course do that with any framework, but if you start a new app and if you are experienced you might like Pyramid the most. Pyramid itself is a somewhat slim core of modules which offer the basics like user management or permissions. If you need anything else, like an ORM you have to install and integrate it yourself.
This mixing and matching is really ideal for apps which go beyond CRUD. You really benefit from designing such an app carefully using the best libs Python has to offer. Not really a framework you want to necessarily start out with as a beginner, but in my opinion the most fun you can have.
At seantis we use Pyramid for our own myControl Pilot Logook. During its (ongoing) development we really appreciate the freedom we have to solve problems our own way or with the packages we chose.
Plone is a CMS in Python. Sometimes you want a CMS. Very often your customer wants a CMS. You might not need a CMS.
If you do need a CMS, Plone is worth a look. The strenghts of Plone are a good security track record (with old releases receiving important fixes years later), a useful architecture for a lot of problems you might have to solve and a friendly and mature community.
It’s weakness is the complexity and its documentation. Plone’s learning curve is steep and frustrating. I used it to write a number of modules for the municipality of Zug, Switzerland. The most important of these modules being a reservation manager for rooms / daycare-center spots and the like.
What’s really great about Plone though is the number of third-party addons you can use. It was quite easy for us to include geo tagging of elements and to add the ability for customers to create their own forms through the web. It is also very easy to set complex permissions or to create intricate workflows.
Plone is the thing you want to use if your customer is big, needs something big and wants to pay different companies for different modules. Think enterprise.
How to get started with Plone is something I might eventually write about, but you cannot really go wrong by reading Professional Plone 4 Development and browsing through the community documentation.
Flask -> One page app
Django -> CRUD app
Pyramid -> Unique app
Plone -> CMS