覆盖基于 class 的通用表单并使用自定义表单的属性?

Attribute to override generic class based form and use a custom form?

我在 forms.py 中有以下表格:

class JobForm(ModelForm):
    class Meta:
        model = Job
        fields = ['title', 'description'] 
        widgets = {'title': TextInput(attrs={'class':'form-control'}),
                   'description': Textarea(attrs={'class':'form-control'})
        }

有什么方法可以让这个视图(和 CreateView)使用上面的表格:

from .forms import JobForm
    class JobUpdateView(UpdateView):
        model = Job
        fields = ['title', 'description']
        template_name = 'job/edit_job.html'
        form = JobForm() # I imagined some attribute like this to specify the form

我刚刚开始使用 class-cased 视图,我觉得这应该很容易通过快速搜索找到。我是否忽略了这里的要点,如果您使用基于 class 的视图,您是否应该不必为 forms.py 定义自定义?

使用 UpdateView 的 form_class 属性 https://docs.djangoproject.com/en/3.0/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin.form_class