Django makemigrations在应用中未检测到更改

编程入门 行业动态 更新时间:2024-10-17 07:31:09
本文介绍了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在应用中未检测到更改

本文发布于:2023-07-14 10:06:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104052.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:检测到   中未   Django   makemigrations

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!