mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Fixed #35913 -- Prevented formset name suffix 'FormFormSet'.
This commit is contained in:
parent
4c452cc377
commit
f60d5e46e1
@ -570,7 +570,12 @@ def formset_factory(
|
||||
"validate_max": validate_max,
|
||||
"renderer": renderer,
|
||||
}
|
||||
return type(form.__name__ + "FormSet", (formset,), attrs)
|
||||
form_name = form.__name__
|
||||
if form_name.endswith("Form"):
|
||||
formset_name = form_name + "Set"
|
||||
else:
|
||||
formset_name = form_name + "FormSet"
|
||||
return type(formset_name, (formset,), attrs)
|
||||
|
||||
|
||||
def all_valid(formsets):
|
||||
|
@ -149,6 +149,12 @@ class FormsFormsetTestCase(SimpleTestCase):
|
||||
self.assertFalse(formset.is_valid())
|
||||
self.assertFalse(formset.has_changed())
|
||||
|
||||
def test_formset_name(self):
|
||||
ArticleFormSet = formset_factory(ArticleForm)
|
||||
ChoiceFormSet = formset_factory(Choice)
|
||||
self.assertEqual(ArticleFormSet.__name__, "ArticleFormSet")
|
||||
self.assertEqual(ChoiceFormSet.__name__, "ChoiceFormSet")
|
||||
|
||||
def test_form_kwargs_formset(self):
|
||||
"""
|
||||
Custom kwargs set on the formset instance are passed to the
|
||||
|
Loading…
Reference in New Issue
Block a user