[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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容