Django 迁移没有推送到 Heroku
Django migrations not pushing to Heroku
我更新了一个 Django 博客,使用 slug urls <slug:slug>/
而不是 id <int:pk>/
。我还在 Article 模型中添加了一个 slugField,并将所有 href 转换为 article.slug
。 运行 迁移和一切在本地运行良好。但是,当我推送到 Heroku 时出现错误。
这是我尝试保存新文章时发生的情况。
ProgrammingError at /admin/articles/article/
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
Request Method: GET
Request URL: https://***********.herokuapp.com/admin/articles/article/
Django Version: 2.1.4
Exception Type: ProgrammingError
Exception Value:
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
我检查了我的 Heroku Postgress 数据库,发现即使我进行了迁移,也没有添加新的 slug 列。我不确定下一步该做什么。我目前正在寻找手动更新 heroku postgress 的方法,但如果有一种侵入性较小的方法来解决这个问题,我会洗耳恭听。
你是先迁移再迁移吗?在上面的评论中向后指出。另外,您确定已将迁移应用到生产数据库吗?它需要将设置标志添加到迁移命令以指向您的生产 settings/db 位置。
首先验证迁移是否已执行 (heroku)
verify that the last migration of the article model is in the django_migrations table
如果您找不到它,请确保您已更新迁移(本地)
python manage.py makemigrations
运行 数据库生产 (heroku) 中的迁移
heroku run python manage.py migrate
我更新了一个 Django 博客,使用 slug urls <slug:slug>/
而不是 id <int:pk>/
。我还在 Article 模型中添加了一个 slugField,并将所有 href 转换为 article.slug
。 运行 迁移和一切在本地运行良好。但是,当我推送到 Heroku 时出现错误。
这是我尝试保存新文章时发生的情况。
ProgrammingError at /admin/articles/article/
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
Request Method: GET
Request URL: https://***********.herokuapp.com/admin/articles/article/
Django Version: 2.1.4
Exception Type: ProgrammingError
Exception Value:
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
我检查了我的 Heroku Postgress 数据库,发现即使我进行了迁移,也没有添加新的 slug 列。我不确定下一步该做什么。我目前正在寻找手动更新 heroku postgress 的方法,但如果有一种侵入性较小的方法来解决这个问题,我会洗耳恭听。
你是先迁移再迁移吗?在上面的评论中向后指出。另外,您确定已将迁移应用到生产数据库吗?它需要将设置标志添加到迁移命令以指向您的生产 settings/db 位置。
首先验证迁移是否已执行 (heroku)
verify that the last migration of the article model is in the django_migrations table
如果您找不到它,请确保您已更新迁移(本地)
python manage.py makemigrations
运行 数据库生产 (heroku) 中的迁移
heroku run python manage.py migrate