Django DateTimeField Armazena data e hora, independentemente do tzinfo
Por que djangoDateTimeField
restaurartzinfo
nodatetime
para<utc>
?
Abaixo está o meu código de teste.
É normal ou errado.?
Se é normal, qual é o motivo?
models.py
class Date(models.Model):
datetime = models.DateTimeField()
settings.py
TIME_ZONE = 'Asia/Seoul'
USE_TZ = True
test.py
from django.utils import timezone
datetime = timezone.localtime(timezone.localtimezone.now())
#now datetime is datetime.datetime(2015, 10, 22, 20, 31, 56, 248000, tzinfo=<DstTzInfo 'Asia/Seoul' KST+9:00:00 STD>)
models.Date(datetime=datetime).save()
#If I check datebase, It shows 2015-10-22 11:31:56.248000
model.Date.object.get(..)
#It returns datetime.datetime(2015, 10, 22, 11, 31, 56, 248000, tzinfo=<UTC>)
Espero lojas django2015-10-22 20:31:56.248000
e retornodatetime.datetime(2015, 10, 22, 20, 31, 56, 248000, tzinfo=<DstTzInfo 'Asia/Seoul' KST+9:00:00 STD>)
--------------Editar----------------
eu useiSqlite
.