Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ResumeForm needs updating.
django 报错
django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ResumeForm needs updating.
一搜网上的回答大都是说加上
fields = '__all__'
看下django.forms.models 中判断报错的源码如下
# If a model is defined, extract form fields from it.
if opts.fields is None and opts.exclude is None:
raise ImproperlyConfigured(
"Creating a ModelForm without either the 'fields' attribute "
"or the 'exclude' attribute is prohibited; form %s "
"needs updating." % name
)
意思就是定义的model没字段 但我有的啊
class ResumeForm(forms.ModelForm):
class Meta:
model = Resume
field = ('title', 'body',)
再仔细一看 fields 写成 field ...
Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ResumeForm needs updating.的更多相关文章
- Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
调试网站时,异常出现:Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. S ...
- .Net Attribute详解(上)-Attribute本质以及一个简单示例
Attribute的直接翻译是属性,这和Property容易产生混淆,所以一般翻译成特性加以区分.Attribute常常的表现形式就是[AttributeName], 随意地添加在class, met ...
- C# Attribute(中)——Attribute本质论
小序: 上篇里,我们把Attribute“粘”在类的成员方法上show了一把,让Attribute跟大家混了个脸儿熟.中篇里,我们将探讨“究竟什么是Attrib ...
- C# Attribute (上)——Attribute初体验
原始出处 .作者信息和本声明.否则将追究法律责任.http://liutiemeng.blog.51cto.com/120361/29201 小序: 注意:本次小序颇长而且没什么 ...
- boolean attribute(布尔值属性) attribute vs property
boolean attribute(布尔值属性) boolean attribute HTML - Why boolean attributes do not have boolean val ...
- Django: ModelForm中Meta的fields等成员介绍
class MyForm(forms.ModelForm): realname = forms.CharField() phone = forms.CharField() class Meta: mo ...
- 特性attribute,声明和使用attribute,应用attribute,AOP面向切面,多种方式实现AOP
1 特性attribute,和注释有什么区别2 声明和使用attribute3 应用attribute4 AOP面向切面5 多种方式实现AOP ---------------------------- ...
- Viser报错:dodge is not support linear attribute, please use category attribute!
遇到这样的问题是因为x轴数据不能为为连续性的日期(日期格式为:YYYY-MM-DD),需要设置为分类属性(cat),有一些可能设置为timeCat,看具体情况 scale 参数支持以下类型 • ide ...
- python---django中form组件(2)自定制属性以及表单的各种验证,以及数据源的实时更新,以及和数据库关联使用ModelForm和元类
自定义属性以及各种验证 分析widget: class TestForm(forms.Form): user = fields.CharField( required = True, widget = ...
随机推荐
- 多线程-Thread和ThreadPool
多线程原理 多线程都是基于委托的. 多线程优缺点 缺点: 1.导致程序复杂,开发调试维护困难,特别是线程交互. 2.线程过多导致服务器卡死,因为占用CPU 内存等资源. 优点: 1.良好的交互,特别对 ...
- Hive SQL NVL 相关函数
1.NVL函数 NVL函数的格式如下:NVL(expr1,expr2)含义是:如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值. NVL(exp ...
- MyBatis 插件之拦截器(Interceptor)
参考 https://blog.csdn.net/weixin_39494923/article/details/91534658 //项目实际使用 就是在你进行数据库操作时,进行数据的第二次封装 ...
- ISO/IEC 9899:2011 条款5——5.1.1 翻译环境
5.1.1 翻译环境 5.1.1.1程序结构 1.一个C程序不需要一次全被翻译完.程序的文本被保存在本国际标准中被称作为源文件(或预处理文件)的单元里.一个源文件连同所有通过指示符#include所包 ...
- 阶段5 3.微服务项目【学成在线】_day09 课程预览 Eureka Feign_02-Eureka注册中心-搭建Eureka单机环境
我们先搭建单机环境 govern是治理的意思, 这样就把工程创建好了 创建包 创建SpringBoot的启动类. 在父工程里面已经确定了Spring Cloud的版本了.相当于锁定了版本 接下里只需要 ...
- C# winform中使用Panel调节窗口变化是各控件的位置(转)
我的目的是在窗口上有些控件,在窗口大小变化时,上面的控件位置不动,大小也不动.下面的控件随着窗口的大小变化而变大. 做法是用两个panel,panelTop和panelFill.上面的控件都放到pan ...
- Python扫描器-常用库-Request
1.常用库-Request 1.1. 介绍 #安装:pip3 install requests #各种请求方式:常用的就是requests.get()和requests.post() >> ...
- 【c# 学习笔记】使用virtual和override关键字实现方法重写
只有基类成员声明为virtual或abstract时,才能被派生类重写:而如果子类想改变虚方法的实现行为,则必须使用override关键字. public class Animal { private ...
- nice-validator表单验证插件
nice-validator表单验证插件的简单使用 前言 前端表单校验是过滤无效数据.假数据.有毒数据的第一步,是数据安全的第一道关卡,虽然我们不能100%相信客户端提交的数据(真正的校验还得在服务端 ...
- Flutter 弹出键盘屏幕溢出问题
在使用输入框获取焦点,弹出键盘的时候,会导致屏幕溢出, 解决办法: resizeToAvoidBottomPadding: false, //输入框抵住键盘 return Scaffold( appB ...