Opened 7 years ago

Closed 6 years ago

Last modified 4 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: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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@…> 7 years ago.
compare_ordering_values.patch (1.6 KB) - added by bmathieu 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Petr Marhoun <petr.marhoun@…>

comment:1 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by bmathieu

comment:2 Changed 6 years ago by bmathieu

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 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 6 years ago by russellm

(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 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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