Ticket #8164: fieldsort.diff

File fieldsort.diff, 870 bytes (added by killiands, 16 years ago)

Patch proposal

  • django/forms/models.py

     
    240240            fields.update(declared_fields)
    241241        else:
    242242            fields = declared_fields
     243        # Sort by order specified in fields
     244        sorted_field_list = []
     245        for f in opts.fields:
     246            if f in fields:
     247                sorted_field_list.append((f,fields.pop(f)))
     248        sorted_fields = SortedDict(sorted_field_list)
     249        # Don't forget to add fields not explicitly mentioned in fields
     250        sorted_fields.update(fields)
    243251        new_class.declared_fields = declared_fields
    244         new_class.base_fields = fields
     252        new_class.base_fields = sorted_fields
    245253        return new_class
    246254
    247255class BaseModelForm(BaseForm):
Back to Top