more compatibility changes to make it work with latest django version