[Python] Model doesn't declare an explicit app_label isn't INSTALLED_APPS

一.前言

今天无意中碰了django, 发现这个问题, 本来不想写的, 但是网上的解决方案写的都跟杂碎一样, 所以这里来声明一下

二.正文

这个问题经常出现于没有导入模块, 比如你在初始模块创建了个model

这时候你引入model它就会报错

RuntimeError: Model class test_django.User.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

解决方案是在settings.py中添加模块名

再次运行就解决了 - -

finally enjoy it.

by objcat

2021.04.09

你可能感兴趣的:([Python] Model doesn't declare an explicit app_label isn't INSTALLED_APPS)