[py3] Avoided comparison with None value in formsets

This commit is contained in:
Claude Paroz 2012-08-13 11:14:08 +02:00
parent 73f0f18c8f
commit 5e958b958b
1 changed files with 6 additions and 5 deletions

View File

@ -95,10 +95,11 @@ class BaseFormSet(object):
total_forms = initial_forms + self.extra total_forms = initial_forms + self.extra
# Allow all existing related objects/inlines to be displayed, # Allow all existing related objects/inlines to be displayed,
# but don't allow extra beyond max_num. # but don't allow extra beyond max_num.
if initial_forms > self.max_num >= 0: if self.max_num is not None:
total_forms = initial_forms if initial_forms > self.max_num >= 0:
elif total_forms > self.max_num >= 0: total_forms = initial_forms
total_forms = self.max_num elif total_forms > self.max_num >= 0:
total_forms = self.max_num
return total_forms return total_forms
def initial_form_count(self): def initial_form_count(self):
@ -108,7 +109,7 @@ class BaseFormSet(object):
else: else:
# Use the length of the inital data if it's there, 0 otherwise. # Use the length of the inital data if it's there, 0 otherwise.
initial_forms = self.initial and len(self.initial) or 0 initial_forms = self.initial and len(self.initial) or 0
if initial_forms > self.max_num >= 0: if self.max_num is not None and (initial_forms > self.max_num >= 0):
initial_forms = self.max_num initial_forms = self.max_num
return initial_forms return initial_forms