Каждый раз, когда я запускаю python manage.py test
, я получаю предупреждение о том, что мои поля модели получили наивные даты и времени:
(venv) C:\Users\Philip\CodeRepos\Acacia2>python manage.py test journal.tests.test_models
Creating test database for alias 'default'...
C:\Users\Philip\CodeRepos\Acacia2\venv\lib\site-packages\django\db\models\fields\__init__.py:1365: RuntimeWarning: DateTimeField Ledger.last_spreadsheet_update received a naive datetime (1970-01-01 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
C:\Users\Philip\CodeRepos\Acacia2\venv\lib\site-packages\django\db\models\fields\__init__.py:1365: RuntimeWarning: DateTimeField JournalEntry.last_integrity_check received a naive datetime (1970-01-01 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
Однако мои модели настроены с датой по умолчанию, включающей часовой пояс:
class Ledger(models.Model):
sort = models.PositiveIntegerField(default=0, blank=False, null=False)
name = models.CharField(max_length=255)
coa_sub_group = models.ForeignKey(COASubGroup, on_delete=models.PROTECT)
is_reconcilable = models.BooleanField(default=False)
spreadsheet_row = models.IntegerField(blank=True, null=True, unique=True)
last_spreadsheet_update = models.DateTimeField(blank=False, null=False, default=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=timezone('UTC')))
class JournalEntry(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=False, blank=False)
date = models.DateField(null=False, blank=False)
# Data integrity check fields
last_integrity_check = models.DateTimeField(blank=False, null=False, default=datetime.datetime(1970, 1, 1, 0, 0, tzinfo=timezone('UTC')))
integrity_check_fail = models.BooleanField(null=False, blank=False, default=0)
Что я могу делать не так?
python manage.py diffsettings
дает:
TIME_ZONE = 'UTC'
USE_L10N = True
USE_TZ = True