无法将类型日期转换为没有时区的时间 LINE 1: ...COLUMN "creation_date" TYPE time USING "creation_date"::time (DJANGO - Heroku)
cannot cast type date to time without time zone 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
。
我已经找到了一些答案,但 none 对我有用。
我已经在settings.py中设置了TIME_ZONE
这是给我错误的迁移:
# 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
我正在尝试将我的 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
。
我已经找到了一些答案,但 none 对我有用。
我已经在settings.py中设置了TIME_ZONE
这是给我错误的迁移:
# 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