[Solved]-Django: Naive datetime while time zone support is active (sqlite)

7👍

So I finally figured it out and I appreciate everyone’s input which got me thinking in the right way:

One of my past migrations had datetime.date.today() as the default value (which is a hint the migrations give). I didn’t think about it because at the time I didn’t even have any data in the model and then, even though that migration had then been migrated again (further down the road), it appears the test system is running every migration each time it starts. So: was getting that warning.

Update: this should be fixed in 1.7.1.

2👍

You are using SQLite database and SQlite db does not have support for timezones. This is causing the warning.

This warning can be removed by using a different DB backend.

If you want to got with sqlite probably putting these lines in settings file can help:

import warnings
import exceptions
warnings.filterwarnings("ignore", category=exceptions.RuntimeWarning, module='django.db.backends.sqlite3.base', lineno=53)  

0👍

Have you installed http://pytz.sourceforge.net/ ?

As soon as you activate time zone support, Django needs a definition of the default time zone. When pytz is available, Django loads this definition from the tz database. This is the most accurate solution. Otherwise, it relies on the difference between local time and UTC, as reported by the operating system, to compute conversions. This is less reliable, especially around DST transitions.

Leave a comment