Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#10082 closed (fixed)

Attribute BaseFormetSet.ordered_forms is broken with blank formsets

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In method BaseFormSet._get_ordered_forms all forms are sorted by function compare_ordering_values. But this function is not defined if the formset is blank.

Attached patch can show problem and fix it.

Attachments (2)

blank-ordered-fieldsets.diff (1.5 KB ) - added by Petr Marhoun <petr.marhoun@…> 16 years ago.
compare_ordering_values.patch (1.6 KB ) - added by bmathieu 16 years ago.

Download all attachments as: .zip

Change History (7)

by Petr Marhoun <petr.marhoun@…>, 16 years ago

comment:1 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

by bmathieu, 16 years ago

comment:2 by bmathieu, 16 years ago

This patch is not the right fix. Basically the problem is that "compare_ordering_values" is defined inside the loop, whereas it is used outside. Thus if the field is empty the loop is never run.
So just define the sorting function where it should be: after the loop, just before "sort".

see attached patch file.

in any case please backport in 1.0.x!

comment:3 by Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: newclosed

(In [10643]) 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.

comment:4 by Russell Keith-Magee, 16 years ago

(In [10644]) [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.

comment:5 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top