toastdriven/django-haystack — pull request #682 by acdha (2012-11-16 21:37:27+00:00)
Title: update_index should use non-naive datetime when settings.USE_TZ=True

After upgrading to Django 1.4 and setting ``USE_TZ = True``, the update_index management command will cause the following warning:

RuntimeWarning: DateTimeField received a naive datetime (2012-11-06 09:33:16.701622) while time zone support is active.

Besides being annoying, this actually breaks if you use an interval less than your GMT offset: for example, on the East Coast ``update_index -a5`` will exclude everything while ``-a 6`` will work.

From first glance, this might be something like a conditional import to use Django 1.4's USE_TZ-aware compatibility layer:

try:
from django.utils.timezone import now
except ImportError:
from datetime import datetime
now = datetime.now