Django model “doesn't declare an explicit app_label”

后端 未结 28 1923
無奈伤痛
無奈伤痛 2020-11-27 15:38

I\'m at wit\'s end. After a dozen hours of troubleshooting, probably more, I thought I was finally in business, but then I got:

Model class django.contrib.co         


        
28条回答
  •  暖寄归人
    2020-11-27 16:14

    I get the same error and I don´t know how to figure out this problem. It took me many hours to notice that I have a init.py at the same direcory as the manage.py from django.

    Before:

    |-- myproject
      |-- __init__.py
      |-- manage.py
      |-- myproject
        |-- ...
      |-- app1
        |-- models.py
      |-- app2
        |-- models.py
    

    After:

    |-- myproject
      |-- manage.py
      |-- myproject
        |-- ...
      |-- app1
        |-- models.py
      |-- app2
        |-- models.py
    

    It is quite confused that you get this "doesn't declare an explicit app_label" error. But deleting this init file solved my problem.

提交回复
热议问题