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 ...
随机推荐
- VMware安装RHEL5.5后修改分辨率设置
1.进入桌面后,点击System -> Administration -> Display,选择Hardware,点击Monitor Type后面的Configure(默认是autocon ...
- [PHP]PHP页面静态化:真静态的两种方案
---------------------------------------------------------------------------------------------- /*|-- ...
- ArcGIS Python编程案例-电子资料链接
ArcGIS Python编程案例(1)-Python语言基础 https://www.jianshu.com/p/dd90816d019b ArcGIS Python编程案例(2)-使用ArcPy编 ...
- GitHub中国区前100名到底是什么样的人?向大佬们学习。
本文转自:码迷 http://www.mamicode.com/info-detail-1267434.html 本文根据Github公开API,抓取了地址显示China的用户,根据粉丝关注做了一个排 ...
- 吴裕雄 python深度学习与实践(1)
#coding = utf8 import threading,time count = 0 class MyThread(threading.Thread): def __init__(self,t ...
- 吴裕雄 python oracle检索数据(1)
import cx_Oracle conn = cx_Oracle.connect("scott/admin@localhost:1521/ORCL")cursor = conn. ...
- Chatbot中的填槽(Slot Filling)(转)
以下内容是学习了@我偏笑发布在公众号hanniman文章后,加上自己观点重新输出配图的文章 原文链接:http://t.cn/RE0FkgD 跳槽,吐槽,匹诺曹都听过,这个填槽,emmmm,黑人问号脸 ...
- MongoDB应用场景
数据记录如下 /* 1 */ { "_id" : ObjectId("5b56dd19a171d7e9bfb03ac1"), "name" ...
- 自动化运维工具Ansible的部署步骤详解
本文来源于http://sofar.blog.51cto.com/353572/1579894,主要是看到这样一篇好文章,想留下来供各位同僚一起分享. 一.基础介绍 ================= ...
- DataGridView中DataGridViewComboBoxColumn的一些相关应用(一)让其值改变时触发事件-转
转自 https://maodaili.de/mao.php?u=a%2FMrbEvUE8PnCuc7FrhJi0Rqd3kmOBHPZUbcJ1c2hbJUK0RYWpAf4lhIOddItP%2 ...