报错:

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. 9.mysql-存储过程.md

    目录 创建 创建 -- 创建存储过程 DELIMITER $ -- 声明存储过程的结束符 CREATE PROCEDURE pro_test() --存储过程名称(参数列表) BEGIN -- 开始 ...

  2. winform下利用webBrowser执行javascript

    目前很多网站为了防止恶意提交表单信息,大多都采用了加密的方式对提交信息进行处理,加密处理后通过POST提交给服务器验证,这种操作一般都是用Javascipt进行加密,若是我们想要正确提交表单到网站,就 ...

  3. 用工厂模式和策略模式优化过多的if-else

    多个if-else代码: @RunWith(SpringRunner.class) @SpringBootTest public class EducationalBackgroundTest { p ...

  4. oracle 连接池参数

    后来排查出数据库监听异常,发现是ORA-12519拒绝错误.后来发现是数据的连接池达到的极致. 具体解决方案如下: --首先检查process和session的使用情况,在sqlplus里面查看. S ...

  5. quast-lg

    1.官网简介 http://cab.spbu.ru/software/quast-lg/ QUAST- lg是QUAST的一个扩展,用于评估大型基因组装配(直至哺乳动物大小).QUAST- lg从5. ...

  6. 什么是webFlux

    什么是webFlux 左侧是传统的基于Servlet的Spring Web MVC框架,右侧是5.0版本新引入的基于Reactive Streams的Spring WebFlux框架,从上到下依次是R ...

  7. java和c#中String

    java中: c#中: 1.拼接字符串 sql语句中 in() str="'001','002','003'";至于产生string就这样  str1="'001'&qu ...

  8. Mybatis批量更新和插入

    <update id="updateOrInsert"> <foreach collection="list" index="ind ...

  9. 大数据入门到精通5--spark 的 RDD 的 reduce方法使用

    培训系列5--spark 的 RDD 的 reduce方法使用 1.spark-shell环境下准备数据 val collegesRdd= sc.textFile("/user/hdfs/C ...

  10. java 连接sqlserver数据库

    1.ResultSet executeQuery(String sql):执行某条查询语句并返回结果public static void main(String[] args) throws Exce ...