Django - makemigrations - No changes detected

前端 未结 30 1515
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 04:44

I was trying to create migrations within an existing app using the makemigrations command but it outputs \"No changes detected\".

Usually I create new apps using the

30条回答
  •  Happy的楠姐
    2020-12-02 05:31

    I had a different issue while creating a new app called deals. I wanted to separate the models inside that app so I had 2 model files named deals.py and dealers.py. When running python manage.py makemigrations I got: No changes detected.

    I went ahead and inside the __init__.py which lives on the same directory where my model files lived (deals and dealer) I did

    from .deals import *
    from .dealers import *
    

    And then the makemigrations command worked.

    Turns out that if you are not importing the models anywhere OR your models file name isn't models.py then the models wont be detected.

    Another issue that happened to me is the way I wrote the app in settings.py:

    I had:

    apps.deals
    

    It should've been including the root project folder:

    cars.apps.deals
    

提交回复
热议问题