summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-04-28 14:22:39 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-04-28 14:22:39 +0000
commitbf10bded7aece13c95a1c3304c14bc9ba803a7b1 (patch)
treeb81f347e66dea21d066e91165bf71f8661173c6d /django/forms
parente114ffb90a87d722493f4e80c32a2a4b5395f75b (diff)
[1.0.X] Fixed #10082 -- Modified BaseFormSet so that ordering checks work when the formset is empty. Thanks to Petr Marhoun for the report and test case, and bmathieu for the fix.
Merge of r10643 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10644 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/formsets.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index a7e27713dc..cd857059d6 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -158,18 +158,18 @@ class BaseFormSet(StrAndUnicode):
# don't add data marked for deletion to self.ordered_data
if self.can_delete and form.cleaned_data[DELETION_FIELD_NAME]:
continue
- # A sort function to order things numerically ascending, but
- # None should be sorted below anything else. Allowing None as
- # a comparison value makes it so we can leave ordering fields
- # blamk.
- def compare_ordering_values(x, y):
- if x[1] is None:
- return 1
- if y[1] is None:
- return -1
- return x[1] - y[1]
self._ordering.append((i, form.cleaned_data[ORDERING_FIELD_NAME]))
# After we're done populating self._ordering, sort it.
+ # A sort function to order things numerically ascending, but
+ # None should be sorted below anything else. Allowing None as
+ # a comparison value makes it so we can leave ordering fields
+ # blamk.
+ def compare_ordering_values(x, y):
+ if x[1] is None:
+ return 1
+ if y[1] is None:
+ return -1
+ return x[1] - y[1]
self._ordering.sort(compare_ordering_values)
# Return a list of form.cleaned_data dicts in the order spcified by
# the form data.