Adapt code to Django 1.6 (issue #49)