python - 如何防止django,将日期转换为utc格式

标签 python oracle django-rest-framework

我在选择时区的约会时间:“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/

相关文章:

django - Django RestFramework Elasticsearch :时间轴API

python - MATLAB 的直方图均衡有什么问题?

java - 类 "ResultSet"和 "executeQuery"是特定于数据库供应商的吗?

java - Camunda 在启动期间在本地 oracle 数据库上引发错误

sql - 条目选择窗口

python - django-rest-framework 非基于 orm 的过滤

python - Django Rest框架在extra_kwargs字典中传递字段错误

python - PyKEP python 开普勒工具箱

python - pyephem next_pass 不匹配天堂之上

python - multiprocessing.Queue 似乎消失了?操作系统(管道破坏)与 Python?