Django

Code

Ticket #3678 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

BaseForm loses field sorting

Reported by: SmileyChris Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

baseform_sorteddict.patch (0.5 kB) - added by SmileyChris on 03/08/07 05:59:08.

Change History

03/08/07 05:59:08 changed by SmileyChris

  • attachment baseform_sorteddict.patch added.

03/08/07 06:12:02 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • needs_docs changed.

03/08/07 23:29:22 changed by mtredinnick

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.

03/08/07 23:34:42 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #3678 (BaseForm loses field sorting)




Change Properties
Action