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 ...
随机推荐
- webpack+avalon+mmState打包方案
终于到讲授如何整合avalon社区这个最强大的组件,基于状态机的路由系统了! 基于状态机的路由系统,据我所知,目前世界上只有三款,angular社区的ui-router, 网易出品的stateman, ...
- 启用Flash Player 11.3的全屏键盘输入注意事项
启用Flash Player 11.3的全屏键盘输入,注意以下事项: 1. HTML代码<param name=”allowFullScreenInteractive” value=”true” ...
- Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans.xsd'
明明项目没错误,但application.xml就报了错误,这是什么问题呢? 问题在于我们找不到org/springframework/beans/spring-beans这个包,也就是我们的spri ...
- HTML 设置字体
HTML,CSS,font-family:中文字体的英文名称 (宋体 微软雅黑) 宋体 SimSun 黑体 SimHei 微软雅黑 Microsoft YaHei 微软正黑体 Microsof ...
- Trustin Lee
Trustin Lee,MINA.Netty2通讯框架的作者韩国人,80年出生,8岁起在MSX迷你计算机上编写BASIC程序,爱好游戏编程以及使用汇编.C和C++解决编程问题,1998年获得韩国信息奥 ...
- 使用tor网络
在www.torproject.org/projects/torbrowser.html.en上找到合适的版本下载 下载好tor浏览器之后,解压双击Tor Browser,出现这个错误 这是因为kal ...
- The <classpath> or <modulepath> for <junit> must include junit.jar if not in Ant's own classpath
The <classpath> or <modulepath> for <junit> must include junit.jar if not in Ant's ...
- 区分action, service和dao
在这里,我们不仅要处理页面逻辑,还要做业务逻辑,还要做数据访问.比如说: public String addUser() { if(user == null) { return FAIL_NO_USE ...
- rancher2 挂载ceph-rbd
一-创建ceph-secret.yml文件 RBD的KEY查看 ceph auth list 复制 client.admin 的key 并使用base64加密 创建ceph-secret.yml ku ...
- nohup top -p 22452 -b >>jiu.log &
解释一下: 1. nohup \$order & 后台执行 2. nohup \$order >>$file & 后台执行,并输入指定文件 3. top -p $num 使 ...