首页 > 解决方案 > 禁止使用不带“字段”属性的 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 

标签: djangodjango-views

解决方案


你有一个错字:from_class而不是form_class.


推荐阅读