Meet Django

20 Nov 2016

With my new job I have been using Django for about two months. Most people say it is a ‘batteries-included’ framework, and indeed, it is. Here I want to give my first impressions about Django, to talk about what are the included ‘batteries’ and what I like and dislike about using it so far.

What Are Included?

Based on my experience with Django so far, useful included batteries are:

  1. A user authentication system so that you do not need to implement your own
  2. Form and field validation is part of the middleware, you only need know how to customize certain parts in the validation chain, and it is not hard; The official documentation is a must-read
  3. Messaging framework to display one-time notification message to the user after processing a form or some other types of user input. In my usecase, it was handy for displaying form validation error message to the user.
  4. Available view decorators to simplify your view handlers
  5. Django Signals to implement ‘Observer Pattern’. This is useful to make the components in a web system decoupled from each other and more event-driven.

What I Like About Django

A good piece of software requires good documentation. Django documentation is huge and comprehensive! According to my experience with Django so far, I could already find most answers and learn important concepts about Django directly in the online documentation directly. Django documentation is really one of its strong points.

Another advantage of Django is it is one of the most popular (and also most mature?!) web frameworks, therefore it is easy to find solutions (including countless plugins and third-party Django apps) and examples to more difficult problems from the opensource community. That means most of the time you do not need to build from scratch. For example, Huey and django-background-tasks are task queue solutions I researched about which have Django integration support (the solution includes an Django app).

What I Dislike About Django

I do not have strong opinions about Django as I haven’t had extensive experience with it yet, however, based on my limited experience so far, I found the template system in Django is inconvenient, because a python function cannot be called from within a template directly, and yet Django let you create a custom template tag or filter to achieve the same thing (then why bother?).

Another thing I found a bit inconvenient is Django’s ORM layer. It seems not flexible and cannot be ‘turned off’.

Some more insights about Django from other people can be found in this blog post.

Summary

My experience with Django is still not enough to judge that much; but once I gain more insights I will update this post to share more.