python - 我似乎无法在没有错误的情况下在 django 中使用 DateTimeField
问题描述
我的 django 博客应用程序具有参数、标题、发布日期、正文和图像。当我在管理页面上创建博客模型时出现错误。这是代码的样子。
ProgrammingError at /admin/blog/blog/add/
column "pub_date" is of type integer but expression is of type timestamp with time zone
LINE 1: ..._date", "image", "body") VALUES ('My first blog', '2020-04-0...
^
HINT: You will need to rewrite or cast the expression.
这是我创建的模型:
from django.db import models
class Blog(models.Model):
title = models.CharField(max_length=250)
pub_date = models.DateTimeField()
image = models.ImageField(upload_to='images/')
body = models.TextField()
解决方案
推荐阅读
- scala - Spark Dataframe stat throwing Task not serializable
- python - 从 HTML 中提取表格信息(作为文本文件)
- python - 为什么我不能在这里使用@staticmethod?
- sql - DEBUG 使用 express 插入 post 查询 SQL
- javascript - Vue如何将adsense脚本注入头部
- acumatica - 根据 Acumatica 中的条件处理子报表,
- cloud-foundry - 我们可以实时更新关键云代工厂的凭证吗?
- java - 春季服务中的状态
- c# - IdentityServer:具有不同授权类型的多个客户端,策略无法正常工作
- reactjs - 我正在尝试使用 AWS SES 在我的 React 应用程序中设置联系我们表单,但出现“CredentialsError: Missing credentials in config”错误