gpt4 book ai didi

django - 提示 : Perhaps you meant to reference the column

转载 作者:行者123 更新时间:2023-11-29 12:49:43 24 4
gpt4 key购买 nike

当我打开页面时,出现错误:

column user_landings_landing.flow_chatbot_id does not exist LINE 1: ...ding"."message", "user_landings_landing"."video", "user_land...
^ HINT: Perhaps you meant to reference the column "user_landings_landing.flow_chatbot".

如何修复它?

我试过`

SELECT "flow_chatbot" FROM user_landings_landing;

SELECT flow_chatbot FROM user_landings_landing;

但这并不是低效的。我得到:

enter image description here

user_landings/models

class Landing(models.Model):
user = models.ForeignKey(
User,
related_name='landings',
verbose_name=_('user')
)
flow_chatbot = models.ForeignKey(Flow, verbose_name=_('Flow chatbot'), blank=True, null=True)
#other fields...

user_landings_landing 表

enter image description here

f = Flow.objects.create(title='aaa', position=1)
Landing.objects.create(
user = User.objects.first(),
slug = 'landing',
flow_chatbot = f
)

django.db.utils.ProgrammingError:关系“user_landings_landing”的列“flow_chatbot_id”不存在

最佳答案

您的表有一个“flow_chatbot”列,Django 期望该列为“flow_chatbot_id”。默认情况下,Django 希望外键列以“_id”结尾。

您可以使用“db_column”属性来指定不同的列名称(例如,如果您尝试将 Django 移植到已经存在的数据库上)。

关于django - 提示 : Perhaps you meant to reference the column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57204821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com