Django TypeError: isinstance() arg 2 must be a type or tuple of types
报错: TypeError: isinstance() arg must be a type or tuple of types
from django.db import modelsfrom django.contrib.auth.models import AbstractUserfrom blog.models import Blog class UserInfo(AbstractUser):
, unique=True)
# USERNAME_FIELD = 'identifier'
nid = models.AutoField(primary_key=True)
# 手机号
telephone = models.CharField(max_length=)
# 用户头像
avatar = models.FileField(upload_to='avatar/', default='avatar/default.png')
# # 用户创建时间
# create_date = models.DateTimeField(auto_now_add=True)
# # 用户博客--一对一对应博客表
blog = models.OneToOneField(to=Blog, to_field='nid', on_delete=models.CASCADE, null=True)
blog app
from django.db import models
# Create your models here.
class Blog(models.Model):
nid = models.AutoField(primary_key=True)
# 博客名称
title = models.CharField(max_length=)
# 站点名称
site_name = models.CharField(max_length=)
# 博客主题样式
theme = models.CharField(max_length=)
当需要关联的表 不在同一个py文件下时
blog = models.OneToOneField(to="Blog", to_field='nid', on_delete=models.CASCADE, null=True)这种写法是错误的, 因为django 无法当做一个模块来导入。所以会因为找不到 而报错。但是所有class都在同一个py文件下,可以用“Blog” 这种方式导入加引号 默认在当前文件里面找,假如Blog在本py文件内 可以to=Blog 但是Blog类要写在这个表上面UserInfo。
Django TypeError: isinstance() arg 2 must be a type or tuple of types的更多相关文章
- Django的urls.py加载静态资源图片,TypeError: view must be a callable or a list/tuple in the case of include().
Django的urls.py加载静态资源图片,TypeError: view must be a callable or a list/tuple in the case of include(). ...
- django错误笔记——TypeError: view must be a callable or a list/tuple in the case of include().解决办法
django增加用户认证模块时,总是提醒模块的url.py中 url(r'^login/$', 'django.contrib.auth.views.login', name='login'),出错: ...
- Django出现的错误1.TypeError: view must be a callable or a list/tuple in the case of include().1.TypeError: view must be a callable or a list/tuple in the case of include().
.TypeError: view must be a callable or a list/tuple in the case of include(). 原因: url(r"^upload ...
- Django TypeError: render() got an unexpected keyword argument 'renderer'
场景: Xadmin添加plugin 来源: 1. xadmin与DjangoUeditor的安装 (第3.3章节) 2. 增加富文本编辑器Ueditor (第14.7章节) 报错: Django T ...
- TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)
报错: TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a str ...
- Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复
网上很多写法都是 type='fanout' 这样的.(这里是基于python=3.6版本, pika=0.13.0 版本) credentials = pika.PlainCredentials(' ...
- TypeError: exchange_declare() got an unexpected keyword argument 'type'
在设置消息广播时:以下代码会报错channel.exchange_declare(exchange='direct_logs', type='direct')TypeError: exchange_d ...
- django 修改urls.py 报错误:TypeError: view must be a callable or a list/tuple in the case of include().
#coding=utf-8 from django.conf.urls import include,url from django.contrib import admin from blog im ...
- django TypeError: 'module' object is not callable
原因:导入模块时直接把模块当函数使用 from rest_framework import reverse #import reverse module @api_view(("GET&qu ...
随机推荐
- 构造函数,C++内存管理,内存泄漏定位
构造函数 1.构造顺序 虚基类构造函数,基类构造函数,类对象构造函数,自己的构造函数 2.必须使用初始化列表 (1) 引用成员,常量成员: (2) 基类没默认构造函数(自己重载覆盖了), (3)类对象 ...
- C#格式化数值结果表(格式化字符串)
字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 string.Format("{0:D3}", ...
- sqlalchemy 学习-- 多表操作
一对多:一对一 # one -- many class Students(Base): __tablename__ = "students" sid = Column(Intege ...
- Win2012&Win2008双系统启动菜单设置
电脑最初安装的是XP,后来想升级操作系统,但XP里又有很多常用软件不想重装,于是装了一个Win2008 R2的双系统,安装好2008R2后,系统自动产生一个2008R2的启动菜单,可以选择进入2008 ...
- you-get
1.打开cmd,输入命令并执行 pip3 install you-get 2.输入命令,检测 You-Get 是否安装成功 you-get 3.开始下载吧 you-get [视频地址]you-get ...
- SAP 优缺点
1.优点: SAP是全球所有ERP产品中对企业构架和财务控制考虑得最细致的系统,也是整体控制逻辑和整体系统结构是最严谨的系统,可以让企业引进先进的管理理念: 对产品在各种行业的适用性考虑得最多的系统, ...
- ggplot2
应用与: http://www.cnblogs.com/batteryhp/p/5232353.html 由于python中matplotlib包的画图功能比较基本,不怎么炫酷,所以想用R中的ggpl ...
- JMeter3.0(三十八)图形化HTML报告中文乱码问题处理(转载)
转载自 http://www.cnblogs.com/yangxia-test 由于个人在JMeter 3.0的实际应用中,脚本中的Test Plan/Sampler等元件命名都没有使用中文,所以在之 ...
- Python基础之列表及元组的增删改查
定义一个列表 晚上的状态不太适合写博客,容易犯困~ 列表的增加有三种方式 第一种主流的增加 append函数 list1 = ['noevil', 'fordearme', 'city', 'cust ...
- matlab画图标题自定义字体大小
title('标题','fontname','Times New Roman','Color','b','FontSize',20);字体是Times New Roman,颜色是蓝色('b'即blue ...