Django ImageField core = False在newforms管理中
时间:2020-03-05 18:44:55 来源:igfitidea点击:
在过渡到newforms管理员时,我很难弄清楚如何为ImageFields指定core = False。
我收到以下错误:
TypeError: __init__() got an unexpected keyword argument 'core'
[编辑]但是,只要删除核心参数,我就会得到"此字段是必需的"。尝试提交时管理界面中的错误。如何使用newforms admin完成core = False意味着做什么?
解决方案
回答
这很简单。我从几个版本开始就遇到了这个问题。基本上,只需在模型的ImageField中删除" core = True"参数,然后按照此处的说明将其转换为newforms管理员使用的内容。
回答
不再使用core
属性。
来自Brian Rosner的博客:
You can safely just remove any and all core arguments. They are no longer used. newforms-admin now provides a nice delete checkbox for exisiting instances in inlines.
回答
要摆脱"此字段是必需的",我们需要通过使用blank = True(如果不是CharField,也可能为null = True)来使其不是必需的。