Original code by project mezzanine/django.