Django - makemigrations - 未检测到更改 [英] Django - makemigrations - No changes detected
问题描述
我试图使用 makemigrations 命令在现有应用程序中创建迁移,但它输出未检测到更改".
I was trying to create migrations within an existing app using the makemigrations command but it outputs "No changes detected".
我通常使用 startapp
命令创建新应用,但在创建该应用时并未将其用于此应用.
Usually I create new apps using the startapp
command but did not use it for this app when I created it.
调试后,我发现它没有创建迁移,因为应用中缺少 migrations
包/文件夹.
After debugging, I found that it is not creating migration because the migrations
package/folder is missing from an app.
如果它不存在或我遗漏了什么,创建文件夹会更好吗?
Would it be better if it creates the folder if it is not there or am I missing something?
推荐答案
要为应用创建初始迁移,请运行 makemigrations
并指定应用名称.将创建迁移文件夹.
To create initial migrations for an app, run makemigrations
and specify the app name. The migrations folder will be created.
./manage.py makemigrations <myapp>
您的应用必须首先包含在 INSTALLED_APPS
中(在 settings.py 中).
Your app must be included in INSTALLED_APPS
first (inside settings.py).
这篇关于Django - makemigrations - 未检测到更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!