在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. 编写C语言的两种方法----Visual Studio/CodeBlocks

    1.CodeBlock(安装简单) 参考这个博客的:https://blog.csdn.net/jjjjkkjkk/article/details/80331625?utm_medium=distri ...

  2. vue 路由知识点(一级路由与二级路由嵌套)

    本人小白一个,如果问题,麻烦大神指点, 一级路由: path:'/' 默认为显示; 二级路由: path: '',默认显示为index组件,因为二级路有没有写index组件,所以使用redirect: ...

  3. Navicat连接远程MySQL8.0数据库

    前言: 如果你有一台服务器,并且安装了Mysql8.0及以上版本数据库.此时想通过本地Navicat软件连接远程服务器上的mysql数据库.那么接下来你就要完成以下准备工作: 登录远程服务器上的数据库 ...

  4. html2canvas.js——HTML转Canvas工具

    我们经常会遇上动态生成海报的需求,而在Web前端中,生成图片非Canvas莫属.但是在实际工作当中,为了追求效率,我们会不可避免地去使用一些JS插件,而html2canvas.js就是一款优秀的插件, ...

  5. 【总结】java基础

    一.基础语法 1.数据类型 (1)基本数据类型:byte(1字节,-27~27-1),short(2字节,-215~215-1),int(4字节,-231~231-1),long(8字节,-263~2 ...

  6. Verification of WISHBONE I2C Master Core(IRUN+Simvision)

    一.前言 很久没写技术博客了,有些懈怠,生活还得继续折腾.转眼工作一年多,时间越长越发觉得自己知之甚少,当然这跟IC行业技术密集有关.用空余时间在opencores网站上下载些小的IP看看 验证下,让 ...

  7. Java学习的第七天

    1.今天学了数组 数组名称.length是数组的长度. 数组打印 二维数组: 多维数组同二维数组类似. 最大值最小值算法. 2.在输入过程中的 定义 int 名=con.nextInt();当时不懂. ...

  8. Maven打包过程

    1.安装maven 下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven- ...

  9. EBAZ4205学习资源整理

    EBAZ4205是一块矿机的控制板,芯片是ZYNQ7010,某鱼上应该不超过30元就能买一块,垃圾佬狂喜 经过不复杂的操作就能进行正常开发,由于货量比较大现在已经有很多大佬写了很多很多好的资料,这里我 ...

  10. 云服务器部署Python项目(nginx+uwsgi+mysql+项目)

    python项目部署到云服务器 关注公众号"轻松学编程"了解更多. 一.硬件准备 云服务器,系统ubuntu_16_04 . 注意:要在安全组中开放Http的80端口. 二.软件准 ...