Python 2.5 compatibility, fixes #261

Tested with Python 2.5.6 and Django 1.4.3.