mirror of https://github.com/django/django.git
Fixed #34349 -- Fixed FormSet.empty_form crash when deleting extra forms is disabled.
This commit is contained in:
parent
278881e376
commit
6cbc403b8e
|
@ -490,7 +490,9 @@ class BaseFormSet(RenderableFormMixin):
|
||||||
required=False,
|
required=False,
|
||||||
widget=self.get_ordering_widget(),
|
widget=self.get_ordering_widget(),
|
||||||
)
|
)
|
||||||
if self.can_delete and (self.can_delete_extra or index < initial_form_count):
|
if self.can_delete and (
|
||||||
|
self.can_delete_extra or (index is not None and index < initial_form_count)
|
||||||
|
):
|
||||||
form.fields[DELETION_FIELD_NAME] = BooleanField(
|
form.fields[DELETION_FIELD_NAME] = BooleanField(
|
||||||
label=_("Delete"),
|
label=_("Delete"),
|
||||||
required=False,
|
required=False,
|
||||||
|
|
|
@ -1480,6 +1480,7 @@ class FormsFormsetTestCase(SimpleTestCase):
|
||||||
self.assertIn("DELETE", formset.forms[0].fields)
|
self.assertIn("DELETE", formset.forms[0].fields)
|
||||||
self.assertNotIn("DELETE", formset.forms[1].fields)
|
self.assertNotIn("DELETE", formset.forms[1].fields)
|
||||||
self.assertNotIn("DELETE", formset.forms[2].fields)
|
self.assertNotIn("DELETE", formset.forms[2].fields)
|
||||||
|
self.assertNotIn("DELETE", formset.empty_form.fields)
|
||||||
|
|
||||||
formset = ChoiceFormFormset(
|
formset = ChoiceFormFormset(
|
||||||
data={
|
data={
|
||||||
|
|
Loading…
Reference in New Issue