Fix AttributeError for older Python/Django

I was getting AttributeError when using Django 1.3.7 with Python 2.6.6.
This commit fixes this issue.