【问题标题】:“ProgrammingError at / relation ”posts_post“ does not exist LINE 1: …evious_post_id”, “posts_post”.“next_post_id” FROM “posts_pos…”“ProgrammingError at / 关系”posts_post“不存在第 1 行:…evious_post_id”、“posts_post”。“next_post_id” FROM “posts_pos…”
【发布时间】:2021-04-06 23:19:13
【问题描述】:

我刚刚用 django 编写了一个博客应用程序,该应用程序在本地运行良好,但在部署时,我收到此错误“OperationalError at / no such table: posts_post”。安装 postgres 后,错误消息更改为“ProgrammingError at / relationship "posts_post" does not exist LINE 1: ...evious_post_id", "posts_post"."next_post_id" FROM "posts_pos..." 请问我该怎么办?

就像我从一开始就尝试部署一个新项目一样,我可以做到这一点而不会出现任何错误,但是当我尝试部署我已经存在的项目时,该项目在我的本地 Windows 机器上使用 Postgres DB 运行良好,但无法迁移关系“posts_post 不存在”的数据和弹出错误。下面可以找到错误的附加屏幕截图。 请让我知道,如果可以使用 Linux 上的 Postgres DB 在本地主机(使用 Django 管理员)上准备的所有数据部署一个成熟的 Django Web 应用程序。

【问题讨论】:

  • 分享您在哪里检索到此错误的视图以及完整的回溯。
  • 您确定设置正确吗:您是否设置了正确的 SQL“方言”?
  • 换数据库后有没有做迁移?
  • 你能告诉我们一些你的代码吗?仅根据错误消息很难找到解决方案
  • 拜托,你必须做 python migrate 因为你没有表

标签: python django postgresql nginx django-models


【解决方案1】:

每次您更改模型或移动到不同/新的数据存储时,您都需要运行 迁移 python manage.py makemigrations https://docs.djangoproject.com/en/3.1/topics/migrations/

【讨论】:

  • 当我运行命令本身时出现错误
猜你喜欢
  • 2021-01-03
  • 2018-04-13
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
  • 2018-10-25
  • 2013-05-06
  • 2020-03-06
  • 1970-01-01
相关资源
最近更新 更多