Django makemigrations在应用中未检测到更改 [英] Django makemigrations No changes detected in app

查看:235
本文介绍了Django makemigrations在应用中未检测到更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的makemigrations命令遇到问题.

I have trouble with my makemigrations command.

注意:到目前为止,我已经成功进行了迁移,因此这不是我第一次尝试对该项目进行迁移.

Note: I have successfully make migrations till now, so it is not the first time I try to make migrations on this project.

我的项目在INSTALLED_APPS中.

I have my project in INSTALLED_APPS.

问题:由于某种原因,项目停止检测我的模型中的任何更改.

Problem: For some reason project stop detecting any changes in my models.

在我的项目models.py中,我有:

Inside my project models.py I have:

from myproject.myfolder import myModel1
from myproject.myfolder import myModel2
from myproject.myfolder import myModel3

如果将新模型添加为myModel4类并将其导入models.py中,我会尝试

if a add new models as myModel4 class and import it inside models.py and I try to

python mamange.py makemigrations environment=local

我得到No changes detected

我知道有很多关于初始迁移的文章,所以我什至尝试

I know there are a lot of posts of making the initial migrations, so I even try

python manage.py makemigrations myproject environment=local

我什至尝试删除__pycache__中的所有文件,但对我来说不起作用.

I even try to delete all files in __pycache__ but it doesn't work for me.

我什至尝试删除数据库并创建一个新数据库,但它也不起作用.

I even try to delete database and create new one, and it doesn't work either.

因为我删除了数据库并再次将其重新设置,所以数据库为空,但是我仍然收到相同的消息.

Because I delete the database and make it new again, database is empty, but I still get same message.

推荐答案

我只是遇到了这样的问题.就我而言,问题是我通过pip安装了正在开发的软件包的稳定版本,而Django正在导入稳定版本而不是开发版本.要检查您是否遇到这种情况,请尝试在models.py中添加语法错误.如果makemigrations没有触发语法错误,那么您将知道python解释器甚至没有加载您的版本.

I just ran into an issue like this. In my case, the problem was that I had installed, through pip, the stable version of the package that I was developing, and Django was importing the stable version rather than my development version. To check if this is the case with you, try adding a syntax error to models.py. If makemigrations doesn't trigger the syntax error, then you'll know that your version is not even being loaded by the python interpreter.

这篇关于Django makemigrations在应用中未检测到更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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