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
|
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.
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!