(admin.E108) The value of 'list_display[0]' refers to 'productname', which is not a callable, an attribute of 'ProductAdmin', or an attribute or method on 'product.Product'.
models.py
# 创建产品表
class Product(models.Model):
productName = models.CharField('产品名称', max_length=64) # 产品名称
productDesc = models.CharField('产品描述', max_length=200) # 产品描述
producter = models.CharField('产品负责人', max_length=200) # 产品负责人
create_time = models.DateTimeField('创建时间', auto_now=True) # 创建时间,自动获取当前时间 class Meta:
verbose_name = "产品管理"
verbose_name_plural = '产品管理' def __str__(self):
return self.productName
admin.py
class ProductAdmin(admin.ModelAdmin):
list_display = ['productname', 'productDesc', 'producter', 'create_time', 'id']
inlines = [ApisAdmin] admin.site.register(Product, ProductAdmin) # 把产品模块注册到Django admin后台并能显示
执行后:
D:\autotestplat>python manage.py makemigrations
SystemCheckError: System check identified some issues: ERRORS:
<class 'product.admin.ProductAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'productname', which is not a callable, an attribute of 'ProductAdmin', or an attribute or method on 'product.Product'.
错误指 在admin.py文件中 'ProductAdmin' 的属性 list_display[0] (即productname) 在models.py 文件中的 Product类中找不到
查找源代码可发现在ProductAdmin类中为productname,而在Product中为 productName,两边未对应,所以报以上错
代码更改并运行:
admin.py
class ProductAdmin(admin.ModelAdmin):
list_display = ['productName', 'productDesc', 'producter', 'create_time', 'id']
inlines = [ApisAdmin] admin.site.register(Product, ProductAdmin) # 把产品模块注册到Django admin后台并能显示
运行:
D:\autotestplat>python manage.py makemigrations
Migrations for 'product':
product\migrations\0001_initial.py
- Create model Product
Migrations for 'apitest':
apitest\migrations\0001_initial.py
- Create model Apis
- Create model Apistep
- Create model Apitest
- Add field Apitest to apistep
Migrations for 'bug':
bug\migrations\0001_initial.py
- Create model Bug
(admin.E108) The value of 'list_display[0]' refers to 'productname', which is not a callable, an attribute of 'ProductAdmin', or an attribute or method on 'product.Product'.的更多相关文章
- <class 'blog.admin.CategoryAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'mame', which is not a callable, an attribute of 'CategoryAdmin', or an attribute or method on 'blog.Category'
系统反馈此类错误是因为行列映射时无法对应: 引起无法对应的原因有: 定义是缺少某列,定义时缩进导致,映射关系时缺少某列,(通俗讲列名对应不上). 这种错误多是python中的 因为其中对于空格的要求是 ...
- (admin.E108) The value of 'list_display[4]'报错解决方案
参考资料:虫师-<web接口开发与自动化测试:基于python语言> 日常学习Django框架中,创建了用户模型,但是页面功能验证时候,提示不能进行列表字段操作,debug好久,才找到问题 ...
- python 一周总结
从7月27前就开始了Djangoj框架的学习到今天一个项目实战已经过了一半了, django给我的感觉就像一个成熟的mov 首先是是数据模型层,Django已经成熟的加入了很多的数据模型供我们所使用 ...
- bbs-admin
目录 引入单例----单例补充 admin---url/注册的自定义配置 解析admin源码 django-admin注册账号-----创建超级用户 python manage.py createsu ...
- Django admin操作
无名小妖 昵称:无名小妖园龄:1年6个月粉丝:22关注:1 +加关注 搜索 常用链接 我的随笔 我的评论 我的参与 最新评论 我的标签 我的标签 Python(1) python3 ...
- 5 Django系列之通过list_display展示多对多与外键内容在admin-web界面下
list_display展示多对多关系的内容 表结构关系 表一 class Server(models.Model): asset = models.OneToOneField('Asset') cr ...
- 4.django笔记之admin
作者:刘耀 QQ:22102107 django-Admin django amdin是django提供的一个后台管理页面,改管理页面提供完善的html和css,使得你在通过Model创建完数据库表之 ...
- django admin site配置(二)
1. ModelAdmin.inlines 将有外键的子类包含进视图 ,实例: class Author(models.Model): name = models.CharField(max_leng ...
- Django admin进阶
1. ModelAdmin.inlines 将有外键的子类包含进视图 ,实例: class Author(models.Model): name = models.CharField(max_leng ...
- Django admin 组件 原理分析与扩展使用 之 sites.py (一)
一 . 前言 Django 提供了admin 组件 为项目提供基本的管理后台功能(对数据表的增删改查). 本篇文章通过 admin源码 简单分析admin 内部原理 ,扩展使用方式,为以后进行定制和自 ...
随机推荐
- 洛谷P1714 切蛋糕(单调队列)
先放代码...... 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=5e5+10,M=0x3f3f3f3f; ...
- Docker | 部署nginx服务
容器时相互隔离的,docker启动的nginx是容器内的服务,不影响我原先服务器上的nginx服务,小伙伴们可大胆尝试 本篇实在linux环境下操作的,主要目的是夺人眼目,对使用Docker部署服务尝 ...
- The project was not built due to "Could not delete '/XXX/WebRoot/WEB-INF/classes/library'.". Fix the problem, then try refreshing this project and building
在构建插件时提示如下错误: Description Resource Path Location Type The project was not built due to "Could n ...
- 微信DAT文件转JPG图片(图片恢复)
微信电脑版现在已经是日常工作生活必不可少的工具,有时候删除了聊天记录或者被系统清理软件清理了,但还想查看曾经的微信聊天图片. 这个时候辛辛苦苦找到了文件,却发现无法查看,因为微信电脑版为了保护我们的隐 ...
- dotnet 用 SourceGenerator 源代码生成技术实现中文编程语言
相信有很多伙伴都很喜欢自己造编程语言,在有现代的很多工具链的帮助下,实现一门编程语言,似乎已不是一件十分困难的事情.我利用 SourceGenerator 源代码生成技术实现了一个简易的中文编程语言, ...
- Linux基础_1_简介
Linux是什么 一款优秀的操作系统软件,特性是一切皆文件:一切设备皆文件!一切设备的设置皆修改配置文件!一切服务的搭建皆修改配置文件!(庞大的树形结构文件系统) 根据FHS标准,Linux目录有以下 ...
- 【Kubernetes】K8s笔记(十一):Ingress 集群进出流量总管
目录 0. Ingress 解决了什么问题 1. Ingress Controller 2. 指定 Ingress Class 使用多个 Ingress Controller 3. 使用 YAML 描 ...
- 一次 Redis 事务使用不当引发的生产事故
这是悟空的第 170 篇原创文章 官网:http://www.passjava.cn 你好,我是悟空. 本文主要内容如下: 一.前言 最近项目的生产环境遇到一个奇怪的问题: 现象:每天早上客服人员在后 ...
- Java多线程(7):JUC(上)
您好,我是湘王,这是我的博客园,欢迎您来,欢迎您再来- 前面把线程相关的生命周期.关键字.线程池(ThreadPool).ThreadLocal.CAS.锁和AQS都讲完了,现在就剩下怎么来用多线程了 ...
- Mybatis-Plus多表联查
表格结构: CREATE TABLE `ssmpdemo`.`person_test` ( `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_gener ...