summaryrefslogtreecommitdiff
path: root/django/forms/formsets.py
diff options
context:
space:
mode:
authorLaurens Verhoeven <12578054+laurensverhoeven@users.noreply.github.com>2023-02-17 21:05:00 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-20 09:04:29 +0100
commit6cbc403b8ee7014bd6dae4892d404eedb1d4a50d (patch)
treed4e0445e0b416d69e9268d51d4145adbc1f73bdf /django/forms/formsets.py
parent278881e37619278789942513916acafaa88d26f3 (diff)
Fixed #34349 -- Fixed FormSet.empty_form crash when deleting extra forms is disabled.
Diffstat (limited to 'django/forms/formsets.py')
-rw-r--r--django/forms/formsets.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 235aaf844c..fd4d53a44f 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -490,7 +490,9 @@ class BaseFormSet(RenderableFormMixin):
required=False,
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(
label=_("Delete"),
required=False,