django - 我还能如何在 postgresql/django python shell 中编写带有时区的时间戳?
问题描述
我正在使用 postgres db 开发 django API 项目。我还添加了一个 serializers.py 文件。我正在尝试通过 python shell 在数据库中添加一行来测试我所做的事情,但我不断收到此错误:
django.db.utils.ProgrammingError: column "date_created" is of type timestamp with time zone but expression is of type time without time zone
LINE 1: ...bility" = NULL, "rating" = NULL, "date_created" = '00:00:00'...
^
HINT: You will need to rewrite or cast the expression.
这是代码:
from vendor.models import Vendors
from vendor.serializers import VendorsRegisterSerializer
p = Vendors(id=1, first_name='Flavio', last_name='Akin', email='sheeku@gmail.com', profession='plumber', username='Flanne', pin='1234', phone_number='12345678901', number_of_jobs=300, number_of_patrons=788, date_created='21:00:00 +05:00')
我尝试将date_created
value'21:00:00 +05:00'
替换为'21:00:00 EST'
,'21:00+05'
但'21:00:00+05'
我不断收到相同的错误。
任何帮助将不胜感激。提前致谢。
解决方案
推荐阅读
- excel - VBA 自动化 - 预填充组合框
- javascript - 从数组中克隆或复制对象,然后使用 es6 推送和重命名
- javascript - 在发布版本中未调用 ChartJs beforeDraw 方法
- python - 制作 tf.function 的任何漂亮方法都包含类实例值?
- javascript - 在 Java 中加载其 javascript init 方法后获取 HTML 文件
- java - Javafx Webview 问题由以下原因引起:javafx.fxml.LoadException:
- glibc - make glibc 2.14 期间“__readlink”的类型冲突
- java - Java中的布尔逻辑表达式
- html - 按钮在响应式布局中不可见
- java - 我们可以根据多种货币获得子组吗?