some code update for new django versions