django - Django 2.1.7: Makemigrations command result: "No change detected in app"
问题描述
(I am aware that a number of Django users have had the same issue.
I have looked at a number of solutions online but none has worked for me so far.)
I have set up my apps.py
, settings.py
and models.py
files as explained in Django official tutorial (please see the 3 files below).
When I enter in the terminal:
$ python3 manage.py makemigrations munichliving_app
It returns:
No changes detected in app 'munichliving_app'
(file settings.py) in INSTALLED_APP --> I added and tested both one at a time: 'munichliving_app' and 'munichliving_app.apps.MunichLivingConfig'
apps.py file: https://pastebin.com/raw/qaYy1x44
setting.py file: https://pastebin.com/raw/cSsbfPsx
models.py: https://pastebin.com/raw/U0QeM16k
Django official tutorial states that I should see something along the lines of:
Migrations for 'polls':
polls/migrations/0001_initial.py:
- Create model Choice
- Create model Question
- Add field question to choice
Thank you.
解决方案
您的应用是munichliving
(包含 的模块models.py
),但您munichliving_app
的INSTALLED_APPS
设置中有。munichlivin_app
是项目文件夹(包含 的文件夹)settings.py
。它通常不包含模型,因此您通常不必将它添加到它INSTALLED_APPS
或为它进行迁移。
替换'munichliving_app'
为'munichliving'
您的INSTALLED_APPS
.
接下来,我会删除你的apps.py
,因为它似乎没有被使用。如果您保留它,请将其更改为name='munichliving', then use
'munichliving.apps.MunichLivingConfig' in
INSTALLED_APPS`。
最后,创建迁移
./manage.py makemigrations munichliving
推荐阅读
- c - realloc():下一个大小无效
- c++ - 加载/存储宽松原子变量和普通变量有什么区别?
- node.js - UnhandledPromiseRejectionWarning:错误:WHERE 参数“用户名”在邮递员中具有无效的“未定义”值
- javascript - InnerText 和 InnerHTML 值未定义,甚至值存在
- typescript - 如何修复命名空间“Joi”没有导出的成员“extractType”
- node.js - 具有异步意外无限循环的节点 JS
- dynamics-crm - MS CRM Online:获取拥有超过 X 个联系人的所有帐户
- python - 如何将dict附加到python中的dict并导出到json文件
- ckeditor - CKEditor 5 提及插件 - 将子元素附加到属性元素
- node.js - 使用特定节点版本与 Azure 一起部署静态 Web 应用程序