Opened 4 years ago
Closed 4 years ago
#33074 closed Cleanup/optimization (invalid)
Do not require fields on UpdateView/CreateView if form specified
Description ¶
When a form class is specified on CreateView or UpdateView, then even though the fields are specified on the form, the following error occurs:
django.core.exceptions.ImproperlyConfigured: Using ModelFormMixin (base class of MyModelCreateView) without the 'fields' attribute is prohibited.
It seems like fields should not have to be specified on a CreateView or UpdateView when a form is specified since fields HAVE to be specified on a form. Why can't the view just use the fields specified on the form? Raising this error when no fields have been specified on the view but a form HAS been specified seems to go against DRY.
Thanks for the report, however specifying both
fields
andform_class
is not permitted andfields
are not checked whenform_class
is specified, see get_form_class(). I'm not sure how you could reach this path withform_class
🤔