Changes for django 1.5 and using new with statement syntax.