RuntimeWarning: DateTimeField received a naive datetime

The problem is not in Django settings, but in the date passed to the model. Here’s how a timezone-aware object looks like:

>>> from django.utils import timezone
>>> import pytz
>>> timezone.now()
datetime.datetime(2013, 11, 20, 20, 8, 7, 127325, tzinfo=pytz.UTC)

And here’s a naive object:

>>> from datetime import datetime
>>> datetime.now()
datetime.datetime(2013, 11, 20, 20, 9, 26, 423063)

So if you are passing email date anywhere (and it eventually gets to some model), just use Django’s now(). If not, then it’s probably an issue with an existing package that fetches date without timezone and you can patch the package, ignore the warning or set USE_TZ to False.

Leave a Comment