Fixes for changes introduced in django 1.5 and 1.7