Compatibility fixes for Django 1.6