Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ResumeForm needs updating.
2024-09-05 03:48:23
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 ...
最新文章
- IOS开发基础知识--碎片49
- mormot 数据集转换为JSON字串
- sqlite3存储格式
- Java 基础知识点(必知必会其一)
- Android开发常用的一些第三方网站
- C#分页类
- C++ 16进制转10进制
- POJ1068Parencodings
- 多线程 (五)NSOperation
- windows 2003 远程桌面 连接输入账号密码后,只能看见蓝色屏幕和鼠标
- feel倍儿爽
- web 直播&;即时聊天------阿里云、融云(三)
- jsp 文件使用 include指令 导入 jspf 分析,及导入jspf 文件后出现乱码问题
- redisLock redis分布式锁
- 502 VS 504
- Java内存管理及对Java对象管理
- RPCZ中的智能指针单例
- Judy Beta 阶段整体计划
- [Docker]CentOS7通过rpm包安装Docker
- 动态导入模块:__import__、importlib、动态导入的使用场景
热门文章
- Macbook上打开多个终端的方法
- 【译】Solr in Action 第二章
- Django 测试开发1
- Java并发包线程池之Executors、ExecutorCompletionService工具类
- SQL-W3School-函数:SQL UCASE() 函数
- 90后外挂开发者:已经有许多主播在我这里在外挂,我月入50W
- Java多线程——线程池使用示例
- 【Leetcode_easy】671. Second Minimum Node In a Binary Tree
- [CareerCup] 2. Bomberman 炸弹人
- 在Win7环境下搭建Geant4工作平台