mirror of
https://github.com/django/django.git
synced 2025-01-08 17:37:20 +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:
|
if self.fields is None:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"Using ModelFormMixin (base class of %s) without "
|
"Using ModelFormMixin (base class of %s) without the 'fields' or "
|
||||||
"the 'fields' attribute is prohibited." % self.__class__.__name__
|
"the 'form_class' attribute is prohibited."
|
||||||
|
% self.__class__.__name__
|
||||||
)
|
)
|
||||||
|
|
||||||
return model_forms.modelform_factory(model, fields=self.fields)
|
return model_forms.modelform_factory(model, fields=self.fields)
|
||||||
|
@ -218,7 +218,7 @@ class CreateViewTests(TestCase):
|
|||||||
|
|
||||||
message = (
|
message = (
|
||||||
"Using ModelFormMixin (base class of MyCreateView) without the "
|
"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):
|
with self.assertRaisesMessage(ImproperlyConfigured, message):
|
||||||
MyCreateView().get_form_class()
|
MyCreateView().get_form_class()
|
||||||
|
Loading…
Reference in New Issue
Block a user