The Tango with Django code rewritten for Django 1.6.5