Update code to comply with django 1.5