Merged nested if statements in BaseFormSet.is_valid().

This commit is contained in:
Windsooon 2017-07-12 14:11:44 -04:00 committed by Tim Graham
parent 138a78ec8c
commit e19b9d6015
1 changed files with 4 additions and 5 deletions

View File

@ -301,11 +301,10 @@ class BaseFormSet:
self.errors self.errors
for i in range(0, self.total_form_count()): for i in range(0, self.total_form_count()):
form = self.forms[i] form = self.forms[i]
if self.can_delete: if self.can_delete and self._should_delete_form(form):
if self._should_delete_form(form): # This form is going to be deleted so any of its errors
# This form is going to be deleted so any of its errors # shouldn't cause the entire formset to be invalid.
# should not cause the entire formset to be invalid. continue
continue
forms_valid &= form.is_valid() forms_valid &= form.is_valid()
return forms_valid and not self.non_form_errors() return forms_valid and not self.non_form_errors()