部署时django CMS错误cms_urlconfrevision [英] django CMS error cms_urlconfrevision on deployment

查看:76
本文介绍了部署时django CMS错误cms_urlconfrevision的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将django CMS应用程序部署到PythonAnywhere或Heroku,但我在Heroku上始终收到此错误:

I'm trying to deploy a django CMS app to PythonAnywhere or Heroku but I keep getting this error on Heroku:

ProgrammingError at /
relation "cms_urlconfrevision" does not exist
LINE 1: ...sion"."id", "cms_urlconfrevision"."revision" FROM "cms_urlco...

以及PythonAnywhere上的此错误:

and this error on PythonAnywhere:

OperationalError at /
no such table: cms_urlconfrevision

该应用程序可以在 localhost 上正常运行.

The app works fine on localhost.

我知道这是一个丢失的数据库表,但是我不知道如何解决它.我尝试删除所有迁移文件和 .pyc 文件,然后再次迁移,我删除了数据库,并尝试使用-fake 进行迁移.似乎什么都没用.

I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.

我正在使用

  • django-cms == 3.6.0
  • Django == 2.1.8

推荐答案

我知道这是一个丢失的数据库表,但是我不知道如何解决它.我尝试删除所有迁移文件和 .pyc 文件,然后再次迁移,我删除了数据库,并尝试使用-fake 进行迁移.似乎什么都没用.

I understand it's a database table missing but I have no idea how to fix it. I tried removing all the migration files and .pyc files and migrated again, I removed the database, I tried migration with --fake. Nothing seems to work.

迁移文件仅定义存在的迁移.他们不会自行修改您的数据库.这里有两个步骤:

Migration files just define what migrations exist. They don't modify your database by themselves. There are two steps here:

  1. 使用 makemigrations 创建迁移.这仅应在您的开发计算机上完成.在部署代码时,您不应进行任何会导致生成新迁移的模型更改.

  1. Creating migrations with makemigrations. This should only be done on your development machine. By the time your code is being deployed you shouldn't have any model changes that would cause new migrations to be generated.

使用 migrate 将迁移应用于数据库.这必须在开发中(以更新本地数据库)以及在生产中(以更新生产数据库)完成.

Applying migrations to your database with migrate. This must be done in development (to update your local database) and also in production (to update your production database).

在Heroku上,您可以使用以下方式进行迁移

On Heroku, you'd run your migrations with

heroku run python manage.py migrate

我认为这是您所缺少的步骤.

I think this is the step you're missing.

这篇关于部署时django CMS错误cms_urlconfrevision的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆