diff options
| author | Laurens Verhoeven <12578054+laurensverhoeven@users.noreply.github.com> | 2023-02-17 21:05:00 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-20 09:33:19 +0100 |
| commit | bb94e1b7dbd42af51d805efafe52b22eb86d5ebe (patch) | |
| tree | 858112a3cf2bcbb8117d74a4955a02ce9d207a9d /django/forms/formsets.py | |
| parent | aab25a69dd09e6717ff86175ff62c29b847a7791 (diff) | |
[4.2.x] Fixed #34349 -- Fixed FormSet.empty_form crash when deleting extra forms is disabled.
Backport of 6cbc403b8ee7014bd6dae4892d404eedb1d4a50d from main
Diffstat (limited to 'django/forms/formsets.py')
| -rw-r--r-- | django/forms/formsets.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py index f14e1aae83..0fa832a248 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -492,7 +492,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, |
