modifying some code for django 1.6 compatability