python - 无法将类型日期转换为没有时区的时间 LINE 1: ...COLUMN "creation_date" TYPE time USING "creation_date"::time (DJANGO - Heroku)
问题描述
我正在尝试将我的 Django 项目上传到 Heroku。我像往常一样运行以下命令:
git add .
git commit -am ""
git push heroku master
heroku run bash
$- python manage.py migrate //this for apply all the migrations
一旦我运行它们,我就得到了cannot cast type date to time without time zone
.
我已经找到了一些答案,但没有一个对我有用。
我已经TIME_ZONE
在 settings.py 中设置了
这是给我错误的迁移:
# Generated by Django 3.1.7 on 2021-08-16 16:29
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('website', '0009_order_creation_date'),
]
operations = [
migrations.AlterField(
model_name='order',
name='creation_date',
field=models.TimeField(default=django.utils.timezone.now, verbose_name='Data Ordine'),
),
]
解决方案
我只是通过重置数据库来解决它。然后我将 DateTimeField 默认值从 timezone.now 更改为 auto_now_add=True
推荐阅读
- javascript - How can I make a regex expression to filter out anything other than numbers and "." dots?
- c# - C# 属性参数的 PascalCase 还是 camelCase?
- asp.net-mvc - 如何从 Asp.Net MVC 中的静态 void 方法刷新 Razor 页面
- redisgraph - RedisInsight:配置图形视觉显示/结果?
- php - iis 对波斯名称文件夹有错误?
- python - 在地图函数中打印出每个可迭代的更简单的方法?
- python - 散景可以动态更新网格图中的列数吗?
- c++ - 在不同类的运算符重载中访问/更改私有变量的问题
- rust - 为什么 Rust 的示例猜谜游戏允许具有不同返回类型的 match 语句?
- auth0 - 无法注销身份提供者 Auth0 Office 插件