Django model “doesn't declare an explicit app_label”

后端 未结 28 1881
無奈伤痛
無奈伤痛 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:05

    O...M...G I was getting this error too and I spent almost 2 days on it and now I finally managed to solve it. Honestly...the error had nothing to do with what the problem was. In my case it was a simple matter of syntax. I was trying to run a python module standalone that used some django models in a django context, but the module itself wasn't a django model. But I was declaring the class wrong

    instead of having

    class Scrapper:
        name = ""
        main_link= ""
        ...
    

    I was doing

    class Scrapper(Website):
        name = ""
        main_link= ""
        ...
    

    which is obviously wrong. The message is so misleading that I couldn't help myself but think it was some issue with configuration or just using django in a wrong way since I'm very new to it.

    I'll share this here for someone newbie as me going through the same silliness can hopefully solve their issue.

提交回复
热议问题