TypeError: __str__ returned non-string (type WebStepInfo)
错误代码:
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)的更多相关文章
- Library string Type
The string type supports variable-length character strings.The library takes cares of managing memor ...
- setLocale(java.util.Locale), setCharacterEncoding(java.lang.String),setContentType(java.lang.String type)
对于setCharacterEncoding(java.lang.String),这个方法是javax.servlet.ServletRequest和javax.servlet.ServletResp ...
- string Type
Notes from C++ Primer Operations Operations of string support lots of operations of sequential conta ...
- 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 ...
- [Cpp primer] Library string Type
In order to use string type, we need to include the following code #include<string> using std: ...
- 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 ...
- 爬虫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. ...
- Django rest framework:__str__ returned non-string (type NoneType) 真正原因
出错原因: 用户表是Django中核心的表,当这个表类字段中有一个这样的函数 def __str__(self): return self.name 在Django用户表设计时候有个字段容易犯这个失误 ...
- 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) ...
- TypeError: validator.settings[("on" + event.type)].call is not a function
昨天遇到此错误信息,下面是调试后正确的代码: $("#inputForm").validate({//inputForm是对应的表单的id onkeyup:false, onfoc ...
随机推荐
- 前端三件套 HTML+CSS+JS基础知识内容笔记
HTML基础 目录 HTML基础 HTML5标签 doctype 标签 html标签 head标签 meta标签 title标签 body标签 文本和超链接标签 标题标签 段落标签 换行标签 水平标签 ...
- Tubian0.42
0.43已发布:https://www.cnblogs.com/tubentubentu/p/16746748.html Sourceforge.net下载:https://sourceforge.n ...
- Vue-amap的使用
(1)Npm安装:npm install vue-amap –save (2)在main.js中配置 首先需要在项目初始化时,通过 initAMapApiLoader 引入所需要的插件: (3)vue ...
- 原生JavaScript
原生JavaScript 为了方便查看. 所有的js和css代码都是嵌入式直接写在html代码中 1.js的引入方式 <!DOCTYPE html> <html lang=" ...
- laravel 浏览器谷歌network返回报错html
laravel 在谷歌报错的时候会返回html,对于调试来说很不方便.原因是在于: 这里返回的格式是json,但是报错时候返回的是整个html所以 相对路径: app\Exceptions\Handl ...
- Redis 常见问题-缓存穿透
问题描述: * 针对 DB 中不存在的数据源,每次请求缓存和数据库都不存在 造成后果: * 应用服务器压力变大 * Redis 命中率大幅度降低 * `数据库压力巨增甚至 down 掉`* 该现象对于 ...
- 二十、Pod的存储之Configmap
Pod 的存储之Configmap 一.Configmap介绍 ConfigMap 功能在 Kubernetes1.2 版本中引入,许多应用程序会从配置文件.命令行参数或环境变量中读取配置信息.Co ...
- 使用 Cravatar 解决 Gravatar 头像无法访问的问题
Gravatar全球通用头像服务 1.基本介绍 Gravatar,即全球公认的头像,是一项免费的头像服务,适用于网站所有者,开发人员以及任何想要轻松且经过验证的在线身份的人.它被内置在每个WordPr ...
- Python 学习思路 思维导图 Xmind
如果需要,请在评论区留下邮箱,我看到后会一次发送.
- Installing ClickHouse-22.10.2.11 on openEuler
一.Installing ClickHouse-22.10.2.11 on openEuler 1 地址 https://clickhouse.com https://packages.clickho ...