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 class apps.user.models.User doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
- 报错解析:apps.user.models 没有声明
原因:当时创建项目时为了简化注册app的写法,所以在setting中加入了apps的路径
sys.path.insert(0, os.path.join(BASE_DIR,'apps'))
然后注册app时就不用apps.
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tinymce',
'cart',
'goods',
'order',
'user',
)
但是当在user.views导入user.models时直接导入
from user.models import User
按这样导入pycharm会有红色波浪线提示,所以又改回原始写法
from apps.user.models import User
这样开启服务器后就会出现上面的报错
这样就会导致Django注册时app为user,但导入使用时是apps.user,所以Django没有找到对应声明的app所以报错
- 解决方法:
方法1.忽略pycharm报错,还是直接导入
from user.models import User
方法2:注册app时不简化写法时用apps.注册
Django开发学习BUG记录--RemovedInDjango19Warning:Model class apps.user.models.User doesn't declare an explicit app_label的更多相关文章
- 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 & ...
- Model class apps.goods.models.GoodsType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
在admin.py注册这个model时,报了个错: RuntimeError: Model class apps.goods.models.GoodsType doesn't declare an e ...
- 在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 ...
- 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 ...
- 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 ...
- django.db.utils.ProgrammingError: (1146, "Table 'db_gold.user_ip_info' doesn't exist") RuntimeError: Model class scanhosts.models.HostLoginInfo doesn't declare an explicit app_label and isn't in an a
Error Msg 创建了一个apps的目录将所有app放入apps文件中, 将apps路径加入sys.path中:sys.insert(0, os.path.join(BASE_DIR, " ...
- 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 ...
- 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 ...
- 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文件 ...
随机推荐
- Echart使用js进行封装成函数
Echart使用js进行封装成函数 主要是对 json 串的封装,使用 js 进行对 json 的解析.之间用的最多是循环取出数组中的值,如果拿去使用可直接修改 json 就好. 上一篇把二维的封装好 ...
- jsp+servlet中文乱码问题
jsp+servlet中文乱码问题 servlet想要获得前台传来的值 String strName=new String(request.getParameter("name") ...
- springboot启动失败( No active profile set, falling back to default profiles: default)
问题: springboot启动失败( No active profile set, falling back to default profiles: default) 解决方法 在pom.xml文 ...
- Openstack组件实现原理 — Glance架构(V1/V2)
目录 目录 Glance 安装列表 Glance Image service Image service 的组件 Glance-Api Glance-Registry Glance-db Image ...
- 关于cefsharp 获取js动态加载后的信息
IFrame frame = null; var identifiers = Browser.GetBrowser().GetFrameIdentifiers(); foreach (var i in ...
- Gerrit Handbook for Commercial Project
前注:常见‘坑’ 不要使用 2.14 版本 gerrit.conf 中 [sendemail] 部分必须有 from = ... 字段,否则无法添加邮箱 gerrit 以用户组为单位划分权限,先将用户 ...
- 9-MySQL-Ubuntu-数据表中数据的修改(二)
数据的修改(update) (1)修改整个字段: update 表名 set 字段1=值1,字段2=值2; (2)修改字段部分数据 update 表名 set 字段1=值1,字段2=值2,... wh ...
- android sdk 下载 最新版。。4.l
android sdk 下载 如今时间 2014.0709.,,这是最新的 64 位 windows 的 .为不能翻墙的小伙伴们准本
- vue实现京东动态楼层效果
页面效果如下 <template> <div> <h1>首页</h1> <section class="floor-nav" ...
- 了解GTIN小记
GTIN为条形码,即"全球贸易项目代码"(Global Trade Item Number ) GTIN用作识别商品品项的全球性独一编码,是编码系统中应用最广泛的标识代码. GTI ...