错误代码:

class CaseStep(models.Model):
id = models.AutoField(primary_key=True)
casetep = models.ForeignKey(WebStepInfo, on_delete=models.CASCADE, verbose_name="测试步骤")
casedata = models.chaCharField("测试数据", max_length=200, default='null')
stepresult = models.BooleanField("测试结果", default=False)
webcase = models.ForeignKey(WebCase, on_delete=models.CASCADE, verbose_name="所属用例")
update_time = models.DateTimeField("最近更改时间", auto_now=True)
create_time = models.DateTimeField("创建时间", auto_now_add=True) class Meta:
db_table = "CaseInfo" def __str__(self):
return self.casetep

在向该表中添加数据时提示__str__ returned non-string (type WebStepInfo),原因是models 中的__str(self)函数返回的都是chaCharField类型,而代码中返回的是(type WebStepInfo)

更改代码:

    def __str__(self):
return self.casetep.stepname

TypeError: __str__ returned non-string (type WebStepInfo)的更多相关文章

  1. Library string Type

    The string type supports variable-length character strings.The library takes cares of managing memor ...

  2. setLocale(java.util.Locale), setCharacterEncoding(java.lang.String),setContentType(java.lang.String type)

    对于setCharacterEncoding(java.lang.String),这个方法是javax.servlet.ServletRequest和javax.servlet.ServletResp ...

  3. string Type

    Notes from C++ Primer Operations Operations of string support lots of operations of sequential conta ...

  4. TypeError: cannot use a string pattern on a bytes-like object的解决办法

    #!/usr/python3 import re import urllib.request def gethtml(url): page=urllib.request.urlopen(url) ht ...

  5. [Cpp primer] Library string Type

    In order to use string type, we need to include the following code #include<string> using std: ...

  6. TypeError: cannot use a string pattern on a bytes-like object

    一劳永逸解决:TypeError: cannot use a string pattern on a bytes-like object TypeError: cannot use a string ...

  7. 爬虫python3:TypeError: cannot use a string pattern on a bytes-like object

    import re from common_p3 import download def crawl_sitemap(url): sitemap = download(url) links = re. ...

  8. Django rest framework:__str__ returned non-string (type NoneType) 真正原因

    出错原因: 用户表是Django中核心的表,当这个表类字段中有一个这样的函数 def __str__(self): return self.name 在Django用户表设计时候有个字段容易犯这个失误 ...

  9. gulp 打包错误 TypeError: Path must be string. Received undefined

    Running gulp gives “path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path) ...

  10. TypeError: validator.settings[("on" + event.type)].call is not a function

    昨天遇到此错误信息,下面是调试后正确的代码: $("#inputForm").validate({//inputForm是对应的表单的id onkeyup:false, onfoc ...

随机推荐

  1. 适合生产制造企业用的ERP系统有哪些?

    什么叫适合?匹配很重要!同是生产制造企业,规模不同.行业不同.发展阶段不同.生产模式不同.管理理念不同,适用的ERP自然也不同.不同规模的企业选用不同的系统,如过你是大型企业,业务管理都比较标准规范, ...

  2. Springboot 之 HandlerMethodReturnValueHandler 运用

    简介 现在项目中大部分采用前后端分离的架构,采用这种架构的项目,在返回数据时,几乎都是采用返回 json 格式的数据.而 spring 中返回 json 格式的数据一般采用 @RestControll ...

  3. 自学Spring

    Spring官网地址https://spring.io/ springManven官网地址:https://mvnrepository.com------------------------ spri ...

  4. InnoDB关于事务、锁、MVCC专题

    目录 并发所带来的的问题 脏写 脏读 不可重复读 幻读 事务 事务的特性 事务的四种隔离级别 锁 为什么要加锁 InnoDB的七种锁 不同事务RR和RC下加锁的规则 MVCC mvcc进一步提高并发 ...

  5. 关于vmware虚拟机的ova/ovf转换成aws上的AMI镜像

    很多时候,我们会有这样的需求,需要将DC中vmware虚拟化的服务器,迁移到aws上,我们就得先将vmware虚拟机导出,然后转换 关于vmvare虚拟的导出备份,一般有ova(Open Virtua ...

  6. 邻接矩阵dfs

    #include<bits/stdc++.h> using namespace std; int a[11][11]; bool visited[11]; void store_graph ...

  7. Vue3 Vite3 状态管理 pinia 基本使用、持久化、在路由守卫中的使用

    在<基于 vite 创建 vue3 项目>一文中整合了 pinia,有不少伙伴不知道 pinia 是什么,本文简单介绍 pinia.主要包括三方面: pinia 的基本用法,在<基于 ...

  8. Vue中使用Switch开关用来控制商品的上架与下架情况、同时根据数据库商品的状态反应到前台、前台修改商品状态保存到数据库

    一般后台对商品的信息管理.包含商品的上架与下架.为了提高用户的体验.将商品上下架的操作做成开关的形式.同时后台数据库中保存的商品状态能够根据开关状态改变. 1.效果展示 这种效果:== 当开关是开启状 ...

  9. Unexpected token u in JSON at position 0

    文章目录 1.1 错误原因: 1.2 解决思路: 1.1 错误原因: 因为JSON.parse()不能解析字符串中的undefined 出错的结果:某一行的这个字段的值为空,就会报错,整个表格都显示不 ...

  10. Java中math类的常用函数

    Java中math类的常用函数 在 Java 中 Math 类封装了常用的数学运算,提供了基本的数学操作,如指数.对数.平方根和三角函数等 只要在源文件的顶部加上下面这行代码就不必在数学方法名和常量名 ...