在admin.py注册这个model时,报了个错:

RuntimeError: Model class apps.goods.models.GoodsType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

admin是这样写的:

from django.contrib import admin
from apps.goods.models import GoodsType # Register your models here.
admin.site.register(GoodsType)

已经把多个应用放到一个文件夹apps,然后在settings也有注册

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tinymce', # 富文本编辑器
'user', # 用户模块
'goods', # 商品模块
'cart', # 购物车模块
'order', # 订单模块 ]

apps的路径也添加进来了

sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))

然后仔细看admin的写法,感觉不太对,把apps去掉就正常了,因为在settings已经添加过这个路径了,所以此时只要从具体的app名导入就好

from django.contrib import admin
from goods.models import GoodsType # Register your models here.
admin.site.register(GoodsType)

Model class apps.goods.models.GoodsType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS的更多相关文章

  1. RuntimeError: Model class apps.users.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

    报错代码: File "/home/bsodgm/Desktop/Django_projection/mall/apps/users/views.py", line 9, in & ...

  2. 在views中引用UserProfile报错RuntimeError: Model class apps.users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

    如图报错,在settings中,该加的也加了啊! 显然类似于网上最容易遇到的解决方案如下图,是没有任何意义的 只要在view中有 from .models import UserProfile,Ver ...

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

    Django 2.x版本迁移数据库报这个错误,user表使用的Django的验证系统 本来就想改一下用户表的表名,莫名的报了个这个错误,在网上找到了解决办法 打开user应用模块下的apps.py文件 ...

  4. Django开发学习BUG记录--RemovedInDjango19Warning:Model class apps.user.models.User doesn't declare an explicit app_label

    报错信息: /home/python/PycharmProjects/dailyfresh/apps/user/models.py:8: RemovedInDjango19Warning: Model ...

  5. RuntimeError: Model class users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

    Django启动的时候报错 File "/home/hehecat/PycharmProjects/MxShop/MxShop/urls.py", line 23, in from ...

  6. RuntimeError: Model class app_anme.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.---python学习错误记录

    untimeError: Model class app_anme.models.User doesn't declare an explicit app_label and isn't in an ...

  7. Django开发BUG "Model class WH_auth.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS."

    当进行数据库迁移的时候发生问题,报错如下:RuntimeError: Model class WH_auth.models.User doesn't declare an explicit app_l ...

  8. Django RuntimeError: Model class app_anme.models.Ad doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.报错

    报错内容 RuntimeError: Model class app_anme.models.Ad doesn't declare an explicit app_label and isn't in ...

  9. RuntimeError: Model class myapp.models.Test doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

    没有添加子应用在settings里面!

随机推荐

  1. Git Push 避免输入用户名和密码方法

    1 创建文件存储GIT用户名和密码 在%HOME%目录中,一般为C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users\中.文件名为.git-cre ...

  2. 一份超全的Python学习资料汇总

    一.学习Python必备技能图谱二.0基础如何系统学习Python?一.Python的普及入门1.1 Python入门学习须知和书本配套学习建议1.2 Python简史1.3 Python的市场需求及 ...

  3. abp(net core)+easyui+efcore实现仓储管理系统——出库管理之三(五十二)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  4. GridView使用SimpleAdapter

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app=&q ...

  5. 当eclipse调用tomcat的时候发生了什么?

    下午在看<tomcat权威指南>的时候想到了这么一个问题:当我在eclipse里调用本机上的一个tomcat运行一个web项目的时候,都发生了什么? 之前做本科毕设的时候用的是MyEcli ...

  6. WTM系列教学视频全免费

    WTM框架问世以来,受到越来越多开发者的喜爱,为了回报大家的厚爱,原本在CSDN上的教学视频已经全部免费,900多分钟的视频,而且还会继续更新. 为了方便大家观看,在B站上也同步更新,地址如下: CS ...

  7. pip intsall 遇到的各种问题

    一.pip install 安装指定版本的包 要用pip 安装指定版本的python的包,只需要通过 == 操作符指定. pip install robotframework == 2.8.7 将安装 ...

  8. shell脚本之文件测试表达式

    1.文件测试表达式的用法 我们在编程时处理一个对象时,需要对对象进行测试,只有符合要求的才采取操作处理:这样做的好处是避免程序出错以及无所畏的消耗系统资源,这个测试的对象可以是文件.字符串.数字等. ...

  9. 跟我一起学.NetCore之EF Core 实战入门,一看就会

    前言 还记得当初学习数据库操作时,用ADO.NET一步一步地进行数据操作及查询,对于查询到的数据还得对其进行解析,然后封装返回给应用层:遇到这种重复而繁琐的工作,总有一些大神或团队对其进行封装,从而出 ...

  10. 题解 AT3877 【[ARC089C] GraphXY】

    参考的博客 在[有趣的思维题]里看到了这道题. 题意: 给出一个\(A\times B\)的矩阵,其中第i行第j列元素为\(d_{i,j}\),试构造一个有向图,满足: 有向图点数\(\le 300\ ...