django - 禁止使用不带“字段”属性的 ModelFormMixin(CreatePostView 的基类)
问题描述
我正在尝试将表单传递给我的 createview,但面临配置不正确的文件错误,并出现以下建议“禁止使用 ModelFormMixin(CreatePostView 的基类)而不使用 'fields' 属性”。
关于如何解决这个问题的任何建议?
class CreatePostView(LoginRequiredMixin,CreateView):
login_url='/login/'
redirect_field_name='blog/post_list.html'
from_class=PostForm
model=Post
#Post Form is name of modelform
解决方案
你有一个错字:from_class
而不是form_class
.
推荐阅读
- speech-recognition - 对话中特定个人的语音到文本
- amazon-sqs - 消费者有没有办法确保没有其他消费者在 SQS 中处理重复的消息?
- c# - 使用 ToolStripMenuItem Owner Item 时如何实现空异常
- algorithm - Prolog indexOf 函数
- java - 如何在没有用户干预的情况下获得 PACKAGE_USAGE_STATS 的权限
- python - Dask Dataframe 一热编码
- javascript - js中值类型的语义副本
- python - 选择 Fernet 加密算法
- haskell - 重新实现 Map.fromListWith 函数
- python - 如何专门使用 pandas 为以下数据总结 3 列并创建新列以标记它是否大于 0 或等于 0