If you’re getting the following error when trying to activate an account using Django 1.4 and django-registration:
can't compare offset-naive and offset-aware datetimes
Then you need to update the source of django-registration manually.
The error file will tell you exactly what file to edit. In this case we need to edit:
registration/models.py
the full path to my file was:
/usr/local/lib/python2.6/dist-packages/registration/models.py
The next step is to import new timezone support:
from django.utils.timezone import utc
Next go to the bottom of the file, and find:
return self.activation_key == self.ACTIVATED or \
(self.user.date_joined + expiration_date <= datetime.datetime.now())
And replace with:
return self.activation_key == self.ACTIVATED or \
(self.user.date_joined + expiration_date <= datetime.datetime.utcnow().replace(tzinfo=utc))
That should work now!
This is only a hack. I'm not even sure if it's correct. So if you do come across this and you can do better, please let me know.
Tags: django, django 1.4, django-registration, error, Python