【发布时间】:2019-01-24 14:17:19
【问题描述】:
我在 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 是我删除的模型。我应该如何进行?我应用了迁移。
提前致谢!
【问题讨论】:
标签: django heroku django-models flush