报错:

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的更多相关文章

  1. 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(). ...

  2. 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'),出错: ...

  3. 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 ...

  4. Django TypeError: render() got an unexpected keyword argument 'renderer'

    场景: Xadmin添加plugin 来源: 1. xadmin与DjangoUeditor的安装 (第3.3章节) 2. 增加富文本编辑器Ueditor (第14.7章节) 报错: Django T ...

  5. 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 ...

  6. Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复

    网上很多写法都是 type='fanout' 这样的.(这里是基于python=3.6版本, pika=0.13.0 版本) credentials = pika.PlainCredentials(' ...

  7. TypeError: exchange_declare() got an unexpected keyword argument 'type'

    在设置消息广播时:以下代码会报错channel.exchange_declare(exchange='direct_logs', type='direct')TypeError: exchange_d ...

  8. 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 ...

  9. django TypeError: 'module' object is not callable

    原因:导入模块时直接把模块当函数使用 from rest_framework import reverse #import reverse module @api_view(("GET&qu ...

随机推荐

  1. css3实现文本渐变

    .gradient-text-one{     background-image:-webkit-linear-gradient(bottom, #00d5fd,#84eaff,#00d5fd); - ...

  2. [PHP]PHPOffice/PHPExcel数据导入方法

    ------------------------------------------------------------------------------------ /** * PHPExcel数 ...

  3. thread == 票池

    public class ThreadDemo2 { public static void main(String[] args){ TicketPool tp = new TicketPool(); ...

  4. 动态修改属性设置 easyUI

    if(条件){  $("#area").combobox({ required:false }); }else{ $("#area").combobox({ r ...

  5. webservice调用dll

    今天客户那里报出来,ws通讯不成功.但是在本机和windows2003上都可以测试成功.WS的页面(asmx)可以出来,但是点击接口方法,调用就报http500错误.   网站无法显示该页面  HTT ...

  6. 使用firefox插件httperrequest,模拟发送及接收Json请求 【转】

    转自[http://blog.csdn.net/feixue1232/article/details/8535212] 目标:使用httpreques\Json-Handle\tcpdump\wire ...

  7. Linux部署项目

    1 安装jdk 第一步:获取Linux系统中jdk安装包和tomcat安装包(后面要用,所以上传两个) 第二步:使用secureCRT客户端工具连到服务器 第三步:使用命令创建一个目录,作为软件的安装 ...

  8. 寒假生活第一天——Github初体验

    快开学了,今天体验了一下github这个对我来说很是神秘的东西 它的定义来源于百度百科,如有异议,那就有吧.//gitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格 ...

  9. 05_ssm基础(三)之Spring基础

    11.spring入门引导 12.spring_HelloWord程序 实现步骤: 0.找到spring压缩包,并解压 1.拷贝jar包 2.添加主配置文件(官方文档约28页) 3.在测试中使用 13 ...

  10. iostat磁盘监控工具

    安装iostat磁盘监控工具 1.安装 yum install sysstat 2.运行 iostat -k -d -x 1 10 -k:以kb为单位统计 -d:显示磁盘状态 -x:显示详细信息 1: ...