我在选择时区的约会时间:“dateTime”:“2019-07-04T17:53:06-05:00”,选择保存方法时,但是在我的BD Oracle中,它可以保存: “2019-07-04T22:53:06”。
我已经设置了 USE_TZ: False。
serializer = self.serializer_class(data=json_data)
if serializer.is_valid():
pas_documento_guardado = serializer.save(usuario=usuario, tercero=tercero)
希望保存在数据库中:"datetime": "2019-07-04T17:53:06",
最佳答案
可能您必须在 Django settings.py
文件中定义正确的 TIME_ZONE
。
来自 Django Docs :
Since Django was first released with the TIME_ZONE set to 'America/Chicago', the global setting (used if nothing is defined in your project’s settings.py) remains 'America/Chicago' for backwards compatibility. New project templates default to 'UTC'.
还有:
When USE_TZ is False, this is the time zone in which Django will store all datetimes.
希望对您有所帮助。
关于python - 如何防止django,将日期转换为utc格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56906659/