Tango With Django: A Review

Published on:
Aug. 26, 2017

I’m working on a new project. This project is bigger in scope than my blog (that you’re reading) and I needed to learn a few new things to get started. I learn best by doing, so I found a book that taught me how to do a lot of new things with Django. That book was Tango With Django.

Tango With Django picked up where the Official Django Tutorial left off, and covered everything needed to make a simple multi-user webapp. Here’s what I think about it.

Tango’s Scope


Tango With Django assumes very little about what you already know. Although it’s helpful to have done the Official Django Tutorial, it’s not necessary. Tango does assume a basic familiarity with Python, using the command line (specifically Bash), and that you will be using a Version Control SystemTango’s code is hosted on GitHub, and several sections of the book refer you to their GitHub repository.

From these humble beginnings, Tango teaches you everything you need to know to make a functional webapp—“Rango”. Rango is an app that lets users post links to websites, assign those websites to categories, and tracks categories by both page click-throughs and “likes” which you implement from scratch.

Even though it sounds simple, building Rango introduced a lot of concepts and technologies that are fundamental to most webapps. Rango covered everything from modeling data to using web APIs and AJAX calls to handle partial page reloads in a client’s browser. I definitely learned a lot going through this book.

The Good


The information in Tango With Django was exceptionally well organized. Even when successive chapters covered wildly different technologies, there was always a logical flow from one topic to the next. I never found myself asking why I was doing a piece of work at any given time; the order just made sense.

Tango also managed to cover an impressively wide range of material. Web Application development is a very broad umbrella, and each piece of a web app can be involved enough that most people specialize in one specific area of app development. Many tutorials hit a point where they have to say something like "[This topic] is outside the scope of this tutorial," but not Tango. At one point there was even an entire chapter on another programming language to implement a feature.

 The Bad


Tango With Django is a book that has been re-released many times. It seems like this may have led to some inconsistencies within the book. At a few points the authors will show a screenshot of a section that doesn’t quite look how it should if you follow along exactly. At others there will be excerpts of files that are slightly different than they were the last time the book had you modify them. Nothing was ever different enough to break any examples, but it was a little unusual.

Tango needs to introduce people to Class-Based Views (CBV). I was surprised that the book never refactored function-based views (FBV) to use Django’s built-in classes. Using Django’s generic CBVs makes your code more readable and abstracts away common functions. For example, here’s an FBV and CBV for displaying a list of objects.

FBV:

def list_categories(request):
    
    context_dict = {}

    categories = Category.objects.all()
    context_dict['categories'] = categories

    return render(request, 'rango/category_list.html', context_dict)

CBV:

class CategoryListView(ListView):

    model = Category
    template = 'rango/category_list.html'

In addition to being shorter, Django’s built in CBVs also have a slew of hooks for adding functionality that you would otherwise have to hand-roll. Django’s built-in classes also do lot of error-handling and exception-raising that the FBV above completely ignores. Not covering CBVs at all is in my opinion Tango With Django’s biggest oversight. Rango wound up having quite a bit of code being re-written by not using the tools Django provides.

The Bottom Line


CBVs aside, Tango With Django was pretty great. If you want to learn how web apps are constructed I highly recommend it. They even make older versions of the book available for free. Overall I’d rate Tango With Django 17/19 chameleons.