From e19b9d601574693e0b9d4769a9c9e4a4ed2fa01e Mon Sep 17 00:00:00 2001 From: Windsooon Date: Wed, 12 Jul 2017 14:11:44 -0400 Subject: [PATCH] Merged nested if statements in BaseFormSet.is_valid(). --- django/forms/formsets.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 0531d50204..1c55d5f6df 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -301,11 +301,10 @@ class BaseFormSet: self.errors for i in range(0, self.total_form_count()): form = self.forms[i] - if self.can_delete: - if self._should_delete_form(form): - # This form is going to be deleted so any of its errors - # should not cause the entire formset to be invalid. - continue + if self.can_delete and self._should_delete_form(form): + # This form is going to be deleted so any of its errors + # shouldn't cause the entire formset to be invalid. + continue forms_valid &= form.is_valid() return forms_valid and not self.non_form_errors()