错误代码:

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. 了解Pytorch|Get Started with PyTorch

    一个开源的机器学习框架,加速了从研究原型到生产部署的路径. !pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple import ...

  2. C#-1 .Net框架

    一 .Net框架组成分为三部分:公共语言运行时CLR.框架类库FCL和编程工具 1.CLR:公共语言运行时(Common Language Runtime): 是一个运行时环境负责代码安全验证.代码执 ...

  3. 工作7年收集到的git命令

    概念 git 中的术语解释: 仓库也叫版本库(repository) stage:暂存区,add 后会存到暂存区,commit 后提交到版本库 git 安装 linux 下安装 git 第一种方法:y ...

  4. PHP全栈开发(五):PHP学习(1.基础语法)

    PHP脚本在服务器上执行,然后将纯HTML的结果返回给浏览器. 听上去很厉害的样子,所以说PHP是服务器端的语言啦.HTML才是前端啦. PHP文件的默认文件扩展名是".php" ...

  5. 详解平衡二叉树(AVL tree)平衡操作(图+代码)

    * 左左就右旋,右右就左旋 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int max ...

  6. 小白转行入门STM32----手机蓝牙控制STM32单片机点亮LED

    @ 目录 引言导读 一.通信基础知识 1.1 通信到底传输的是什么? 1.2 比特率和波特率 习题 1.1 双工和单工 习题 1.2 串行和并行 1.3 异同通信和同步通信 习题 二.连接STM32单 ...

  7. 2022-08-12-esp32把玩记-②_用Micropython点ssd1306_oled屏幕

    layout: post cid: 8 title: esp32把玩记-② 用Micropython点ssd1306 oled屏幕 slug: 8 date: 2022/08/12 15:12:39 ...

  8. MySQL的日志文件

    本文将重点介绍MySQL的日志文件类型,并讲解其作用,并结合一定实操演示,相信跟着做下来你会对MySQL有更深的理解. 文件的概念 在开始讲MySQL日志文件之前,首先我们要明确一下文件的概念.MyS ...

  9. js排序的基础原理理解

    在了解数组排序前,我们先了解下如何交换两个数字的位置 假设我们有这么一个数组 var arr=[1,2,3] 我们想交换1和3两个的位置我们该如何做呢? 最简单的肯定是手动赋值,如下 var arr= ...

  10. HTML+CSS基础知识(4)简单的广告界面

    文章目录 1.网页实例 1.1 代码 1.2 测试效果 1.网页实例 1.1 代码 css样式 /* 清除页面样式 */ *{ margin:0; padding: 0; } /* 统一页面的样式 * ...