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 ...
随机推荐
- 如何遍历Set对象
对 set 的遍历 1.迭代遍历: Set<String> set = new HashSet<String>(); Iterator<String> it = s ...
- jQuery链式语法演示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- app开发中读取数据库信息的vue页面
<template> <!-- 容器 --> <div class="container"> <!-- 标头 --> <div ...
- C++ 使用VS2010创建MFC ActiveX工程项目
1.ActiveX的基本概念 ActiveX控件可以看作是一个极小的服务器应用程序,它不能独立运行,必须嵌入到某个容器程序中,与该容器一起运行.这个容器包括WEB网页,应用程序窗体等... Activ ...
- spring boot 程序打jar包及运行
- /src/log4j2.xml
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="warn ...
- k8s operator
https://coreos.com/blog/introducing-operators.html Site Reliability Engineer(SRE)是通过编写软件来运行应用程序的人员. ...
- ABAP表控件查询
1.准备工作 首先SE11自建一个数据库表(数据元素,域信息请提前建好) 2.编写代码 2.1 新建一个子屏幕 子屏幕中需新定义一个文本输入框,命名为:key_word,新建一个表控件,命名为tab, ...
- javascript学习笔记(七):事件详解
HTML事件处理 <!DOCTYPE html> <html> <head lang="en"> <meta chaset="U ...
- Mysql 单表操作、增删查改(基础4)
新建一个表,往里面插入数据. #新建一个表 mysql> create table test( -> id int, -> name varchar(20) -> );Quer ...