问题
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...
and this error on PythonAnywhere:
OperationalError at /
no such table: cms_urlconfrevision
The app works fine on localhost
.
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.
I'm using
- django-cms==3.6.0
- Django==2.1.8
回答1:
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:
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.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).On Heroku, you'd run your migrations with
heroku run python manage.py migrate
I think this is the step you're missing.
回答2:
Hello maybe you found the solution but if the is somebody coming across that issue, it due to the database settings.
In project_name/site_name/settings.py and database settings section
Change
NAME: 'project.db'
to
NAME:'project_name/project.bd'
来源:https://stackoverflow.com/questions/56283143/django-cms-error-cms-urlconfrevision-on-deployment