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, "apps")) 未改前:
RuntimeError: Model class scanhosts.models.HostLoginInfo doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. 安装app到install_apps中后, 变成:
django.db.utils.ProgrammingError: (1146, "Table 'db_gold.user_ip_info' doesn't exist")
原因及解决:
1. 没有安装apps, 在setting.py中安装app
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"users",
"scanhosts",
"details"
]
2. 安装app后, 所有用到app中的模块导入必须使用app.模块名, 不能使用上级目录apps
只能使用:
from scanhosts.utils import login_ssh_do
from scanhosts.models import *
不能使用:
from apps.scanhosts.utils import login_ssh_do
from apps.scanhosts.models import *
3. 如果无法迁移, 可指定迁移model来迁移:
python manage.py makemigrations users scanhosts details
python manage.py migrate
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的更多相关文章
- 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 ...
- django.db.utils.ProgrammingError: 1146 的解决办法
在models中设置完数据库相关的东西后执行命令 python manage.py makemigrations 此处无错误 再次执行 python manage.py migrate 发生报错 错误 ...
- django.db.utils.ProgrammingError: 1146 解决办法
出现原因: 因为直接在mysql中删除了表或者在执行过一次迁移后,在modles中修改了表名及对应的方法和引用 产生后果: 1.迁移的过程中可能出现表不存在的报错情况 2.迁移过程没有报错,在admi ...
- 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 ...
- Why getting this error “django.db.utils.OperationalError: (1050, ”Table 'someTable' already exists“)”
0down votefavorite I am getting error like django.db.utils.OperationalError: (1050, "Table 's ...
- django.db.utils.OperationalError: (1050, "Table '表名' already exists)解决方法
django.db.utils.OperationalError: (1050, "Table '表名' already exists)解决方法 找到解决方案,执行: python mana ...
- django.db.utils.OperationalError: (1050, "Table 'article_category' already exists")
(转自:https://blog.csdn.net/huanhuanq1209/article/details/77884014) 执行manage.py makemigrations 未提示错误信息 ...
- 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 ...
- django.db.utils.InternalError: (1050, "Table 'tb_content' already exists")
在goods应用里面写了tb_content数据表的模型类(不该写在这里的),进行了数据迁移,还导入了数据. 在contents应用里也写了tb_content数据表的模型类(应该写在这里的), 解决 ...
随机推荐
- Pytorch系列教程-使用字符级RNN生成姓名
前言 本系列教程为pytorch官网文档翻译.本文对应官网地址:https://pytorch.org/tutorials/intermediate/char_rnn_generation_tutor ...
- Mysql查询的一些操作(查表名,查字段名,查当月,查一周,查当天)
查询数据库中所有表名 select table_name from information_schema.tables where table_schema='tools' and table_typ ...
- 团队选题报告(bull beer)
一.团队成员及分工 团队名称:bull beer 团队成员: 黄文东:选题报告word撰写 沈培:原型设计,博客撰写,ppt制作 邓泽中:住院 刘帅:查找相关资料 二.选题报告内容 项目名称:学费管理 ...
- ConfirmCancelDialog【确认取消对话框】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 对确认取消对话框的封装. 前提:调用对话框的Activity必须继承FragmentActivity及其子类(比如AppCompat ...
- window.localStorage的用法
一.什么是localStorage.sessionStorage 在HTML5中,新加入了一个localStorage特性,这个特性主要是用来作为本地存储来使用的,解决了cookie存储空间不足的问题 ...
- 解读 kubernetes client-go 官方 examples - Part Ⅰ
目录 1. 介绍 2. 运行测试 2.1 测试环境 2.2 运行结果 3. 原理解析 3.1 获取 kubeconfig 信息,并构造 rest#Config 实例 3.1.1 tools/clien ...
- .NET西安社区 [拥抱开源,又见 .NET] 第二次活动简报
「拥抱开源, 又见 .NET」 随着 .NET Core的发布和开源,.NET又重新回到人们的视野. .NET Core的下个3.0即将release,加入非常多的新功能,越来越拥抱变化,DevOps ...
- Django-restframework之路由控制、解析器及响应器
django-restframework之路由控制.解析器及响应器 一 前言 本篇博客介绍 restframework 框架的剩下几个组件,路由控制有三种:传统路由.半自动路由及全自动路由:解析器是用 ...
- 【经典案例】Python详解设计模式:策略模式
完成一项任务往往有多种方式,我们将其称之为策略. 比如,超市做活动,如果你的购物积分满1000,就可以按兑换现金抵用券10元,如果购买同一商品满10件,就可以打9折,如果如果购买的金额超过500,就可 ...
- sql:常用函数
1.验证是否是null,是则替换ISNULL(Weight, 50) SELECT AVG(ISNULL(Weight, 50))FROM Production.Product; 2.连接多个字符串 ...