首页 > 解决方案 > 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.

标签: django

解决方案


您的应用是munichliving(包含 的模块models.py),但您munichliving_appINSTALLED_APPS设置中有。munichlivin_app是项目文件夹(包含 的文件夹)settings.py。它通常不包含模型,因此您通常不必将它添加到它INSTALLED_APPS或为它进行迁移。

替换'munichliving_app''munichliving'您的INSTALLED_APPS.

接下来,我会删除你的apps.py,因为它似乎没有被使用。如果您保留它,请将其更改为name='munichliving', then use'munichliving.apps.MunichLivingConfig' inINSTALLED_APPS`。

最后,创建迁移

./manage.py makemigrations munichliving

推荐阅读