Leaklens

django__django-16569

Formsets' add_fields() method fails in some circumstances if the argument index is None.

Verdict: the fix is stated in the issue (Tier A).

Checking for index not None should fix the issue: if self.can_delete and (self.can_delete_extra or (index is not None and index < initial_form_count)):

The text states the fix: “Checking for index not None should fix the issue: if self.can_delete and (self.can_delete_extra or (index is not None and index < initial_form_count)):”

All SWE-bench Verified tasks · more django/django tasks · How the check works