Fixes for Django 1.5

See https://code.djangoproject.com/ticket/18899 for more information.

Additionally, the Site.objects.. call didn't work for me as written, so
I made it occur in a closure.
Merge branch 'django_15_fixes' into localwiki