Ticket #10082: compare_ordering_values.patch

File compare_ordering_values.patch, 1.6 KB (added by bmathieu, 15 years ago)
  • django/forms/formsets.py

    old new  
    158158                # don't add data marked for deletion to self.ordered_data
    159159                if self.can_delete and form.cleaned_data[DELETION_FIELD_NAME]:
    160160                    continue
    161                 # A sort function to order things numerically ascending, but
    162                 # None should be sorted below anything else. Allowing None as
    163                 # a comparison value makes it so we can leave ordering fields
    164                 # blamk.
    165                 def compare_ordering_values(x, y):
    166                     if x[1] is None:
    167                         return 1
    168                     if y[1] is None:
    169                         return -1
    170                     return x[1] - y[1]
    171161                self._ordering.append((i, form.cleaned_data[ORDERING_FIELD_NAME]))
    172162            # After we're done populating self._ordering, sort it.
     163
     164            # A sort function to order things numerically ascending, but
     165            # None should be sorted below anything else. Allowing None as
     166            # a comparison value makes it so we can leave ordering fields
     167            # blamk.
     168            def compare_ordering_values(x, y):
     169                if x[1] is None:
     170                    return 1
     171                if y[1] is None:
     172                    return -1
     173                return x[1] - y[1]
    173174            self._ordering.sort(compare_ordering_values)
    174175        # Return a list of form.cleaned_data dicts in the order spcified by
    175176        # the form data.
Back to Top