Micro frameworks have become all the rage. They are small and sexy and you can find them everywhere.
Django is not considered a micro framework, but recently I looked at other frameworks some of which are considered micro and I realized that in fact it is.
What is so cool about micro frameworks?
- Easy to install
- Few or no external dependency
- Start quickly with just few lines of code
- Convention over configuration
- Use only what you want
- Easily add more functionality
- No need of a complex folder structure
- Lightweight in resources
- Lightweight in code base
These are not hard rules, but they apply to what I consider a micro framework. With the exception of the last rule, Django abides by all of them.
Django is easy to install, “pip install django” and it’s done.
An initial Django app has only 5 files and you can create the rest of your app in one file, if you wish. It’s a little bit more then Flask (only one file), but it is way much less than Rails (tons of folders, sub-folders and files).
Django is pluggable and extensible. You can easily add more functionality if you need it or replace existing functionality with something else, and all other components will work seamlessly.
Recently Cloudant chose to use Flask instead of Django. Their two main reasons where:
- No imposed ORM
- Existing Authentication/Authorization in Erlang
Django comes bundled with an ORM, but it is not imposed and if you don’t want to use it, you can use something else or access directly your database just as easily as you will do it in Flask. The same goes for the Django’s authentication. It’s there but if you don’t want to use it, you can use anything else just as easily as you can do it in Flask.
The only thing that Django does not cover from my list above is the lightweight on code base. This is mainly because Django comes with batteries included. However, I am not forced to use any of them, they don’t put extra weight in terms of resources when not used and they don’t clash with other python packages. So even with the baterries Django is very light.
Before I had one more rule. A micro framework should be able to focused on doing one thing and only one very well. However, most things that are considered micro frameworks does not abide this rule, including Flask (just look at its tutorial, its bigger than Django’s and covers almost the same things as Django’s).