mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Improved ImproperlyConfigured error message in ModelFormMixin.
Clarified that either 'fields' or 'form_class' attribute must be set when using ModelFormMixin.
This commit is contained in:
parent
43287cbb87
commit
3e4527cc87
@ -101,8 +101,9 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
|
||||
|
||||
if self.fields is None:
|
||||
raise ImproperlyConfigured(
|
||||
"Using ModelFormMixin (base class of %s) without "
|
||||
"the 'fields' attribute is prohibited." % self.__class__.__name__
|
||||
"Using ModelFormMixin (base class of %s) without the 'fields' or "
|
||||
"the 'form_class' attribute is prohibited."
|
||||
% self.__class__.__name__
|
||||
)
|
||||
|
||||
return model_forms.modelform_factory(model, fields=self.fields)
|
||||
|
@ -218,7 +218,7 @@ class CreateViewTests(TestCase):
|
||||
|
||||
message = (
|
||||
"Using ModelFormMixin (base class of MyCreateView) without the "
|
||||
"'fields' attribute is prohibited."
|
||||
"'fields' or the 'form_class' attribute is prohibited."
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, message):
|
||||
MyCreateView().get_form_class()
|
||||
|
Loading…
Reference in New Issue
Block a user