updated code to run on Django 1.6 (1.6.2).