Opened 10 years ago

Closed 10 years ago

#3678 closed (fixed)

BaseForm loses field sorting

Reported by: Chris Beaven Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Came across this in a project just now when I had overridden BaseForm for a special form of my own. The fields were coming out in a different order from what I had specified.

The reason is that the __init__ of BaseForm does:

self.fields = self.base_fields.copy()

Even if base_fields is a SortedDict, .copy() is just the normal dict function so fields becomes a dict class and loses field sorting.

Simple patch attached.

Attachments (1)

baseform_sorteddict.patch (561 bytes) - added by Chris Beaven 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by Chris Beaven

Attachment: baseform_sorteddict.patch added

comment:1 Changed 10 years ago by Simon G. <dev@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 10 years ago by Malcolm Tredinnick

You're trying to fix this in the wrong place. We should fix the copy() method for SortedDict classes. I'll commit a fix shortly.

comment:3 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [4688]) Fixed #3678 -- Implemented SortedDict.copy().

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