Port compatibility fix for Django 1.5

from https://bitbucket.org/romanalexander/django-tracking