我在Heroku上部署了我的应用程序,从网站运行所在的本地服务器上可以完美地看到它。问题是,每当我尝试在Heroku网站(https://awayfromspain.herokuapp.com/admin/)中以管理员身份进入时,都会出现以下错误:
ProgrammingError at /admin/
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
当我尝试输入与模型相关的页面时,我也会得到这个信息:
column myapp_experience.slug does not exist
LINE 1: ...p_experience"."title", "myapp_experience"."text", "myapp_exp...
我认为我的数据库有问题...但是我尝试刷新并得到:
Running python manage.py flush on ⬢ awayfromspain... up, run.2445 (Free)
You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'df1neimk7ipkd5' database,
and return each table to an empty state.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
CommandError: Database df1neimk7ipkd5 couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL: Table "myapp_franceexperience" references "auth_user".
HINT: Truncate table "myapp_franceexperience" at the same time, or use TRUNCATE ... CASCADE.
在franceexperience是我删除的模型。我应该如何进行?我应用了迁移。
谢谢!
答案 0 :(得分:0)
您的迁移显然不同步;删除模型时,应该已经删除了franceexperience。
您应该在本地再次进行迁移,并检查它是否添加了迁移以删除该表。然后提交您的代码,推送它,然后执行heroku run ./manage.py migrate
;这应该删除已删除的表,但也希望添加丢失的会话表。