Compatibility fixes with Django master