我收到此錯誤的Django的模型:Django的給神祕的錯誤爲外鍵
ProgrammingError at /admin/notifications/eventtoken/ column notifications_eventtoken.user_id does not exist LINE 1: ...ications_eventtoken" INNER JOIN "users_user" ON ("notificat... ^ HINT: Perhaps you meant to reference the column "notifications_eventtoken.used_at".
我添加了用戶這樣一個外鍵:
class EventToken(models.Model):
token = models.CharField(max_length=255, db_index=True)
user = models.ForeignKey(User, null=False, blank=False)
used_at = models.DateTimeField(null=True, blank=True)
event = models.ForeignKey(Event)
它的工作原理,當我刪除用戶字段,但除此之外,我不能告訴錯誤信息。
您可以添加完整的錯誤堆棧跟蹤嗎? –
您是否在添加新的'user'字段後運行遷移?即您的數據庫表是否與您的模型保持同步? –