即使在运行迁移后,Django编程错误列也不存在 [英] Django Programming error column does not exist even after running migrations

查看:56
本文介绍了即使在运行迁移后,Django编程错误列也不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行 python manage.py makemigrations ,我得到:
未检测到任何更改
然后, python manage.py迁移,我得到:
没有要应用的迁移。

I run python manage.py makemigrations and I get: No changes detected Then, python manage.py migrate and I get: No migrations to apply.

然后,我尝试将更改推送到生产中:
git push heroku master
一切都是最新的

Then, I try to push the changes to production: git push heroku master Everything up-to-date

然后,在生产中,我重复命令:
heroku运行python manage.py

Then, in production, I repeat the command: heroku run python manage.py migrate No migrations to apply.

以防万一,我在生产环境中运行了 makemigrations

Just in case, I run makemigrations in production:

heroku run python manage.py makemigrations
No changes detected

为什么,然后在...处出现

WHY then I get a

ProgrammingError at ....

column .... does not exist

未检测到更改表示数据库与代码一致。
我该如何调试?¡

"No changes detected" means the database is coherent with the code. How can I debug this?¡?

推荐答案

Django迁移记录在数据库的 django_migrations表下。这就是Django如何知道已应用哪些迁移以及仍需要应用哪些迁移的方式。

Django migrations are recorded in your database under the 'django_migrations' table. This is how Django knows which migrations have been applied and which still need to be applied.

看看数据库中的django_migrations表。应用迁移时可能出了点问题。因此,请删除表中具有与不存在列相关的迁移文件名的行。然后,尝试重新运行迁移。

Have a look at django_migrations table in your DB. It may be that something went wrong when your migration was applied. So, delete the row in the table which has the migration file name that is related to that column that 'does not exist'. Then, try to re-run a migration.

这篇关于即使在运行迁移后,Django编程错误列也不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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