summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-08-13 11:14:08 +0200
committerClaude Paroz <claude@2xlibre.net>2012-08-13 11:54:13 +0200
commit5e958b958b4b27082a393decf64ec573fa7454b2 (patch)
treec7ef929373901b525b57b3d051ac18d63f554ade
parent73f0f18c8fc04a03bbfb20794aabb95944c90f63 (diff)
[py3] Avoided comparison with None value in formsets
-rw-r--r--django/forms/formsets.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 258c673da8..1e8edfdb79 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -95,10 +95,11 @@ class BaseFormSet(object):
total_forms = initial_forms + self.extra
# Allow all existing related objects/inlines to be displayed,
# but don't allow extra beyond max_num.
- if initial_forms > self.max_num >= 0:
- total_forms = initial_forms
- elif total_forms > self.max_num >= 0:
- total_forms = self.max_num
+ if self.max_num is not None:
+ if initial_forms > self.max_num >= 0:
+ total_forms = initial_forms
+ elif total_forms > self.max_num >= 0:
+ total_forms = self.max_num
return total_forms
def initial_form_count(self):
@@ -108,7 +109,7 @@ class BaseFormSet(object):
else:
# Use the length of the inital data if it's there, 0 otherwise.
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
return initial_forms