【问题标题】:relation "django_session" does not exist - django, heroku关系“django_session”不存在 - django,heroku
【发布时间】: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


    【解决方案1】:

    您的迁移显然不同步; franceexperience 应该在您删除模型时已被删除。

    您应该在本地再次进行迁移并检查它是否添加了迁移以删除该表。然后提交您的代码,推送它,然后执行heroku run ./manage.py migrate;这应该删除已删除的表,但也希望添加缺少的会话表。

    【讨论】:

    • 我做了: 1. python manage.py makemigrations; 2. python manage.py 迁移; 3. git添加.; 4.git状态; 5. git commit -m "初始提交"; 6. git push heroku master; 7. heroku 运行 python manage.py migrate 并没有改变...
    • makemigrations 是否真的创建了任何迁移?这是你的“初始提交”吗?
    • 它在它的时代做到了......我做了几次这个步骤期待一些东西,据我所知,它删除了法国的经验。好吧,我总是在写初始提交,名字重要吗:O?我以为它在更新自己
    猜你喜欢
    • 2020-10-02
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 2018-07-16
    • 2016-11-03
    • 2016-04-11
    • 2016-06-20
    相关资源
    最近更新 更多