Ticket #6369: modelfield_order_3.2.diff

File modelfield_order_3.2.diff, 876 bytes (added by Luke Garner <dj-t@…>, 17 years ago)

ModelField fields ordering (now with error handling)

  • django/newforms/models.py

     
    257257            attrs['base_fields'] = model_fields
    258258        else:
    259259            attrs['base_fields'] = declared_fields
     260        # If Meta defines fields, they should be outputed in the order specified.
     261        # But first check to ensure that all items in Meta.fields actually exist.
     262        if opts.fields:
     263            for key in opts.fields:
     264                if not key in attrs['base_fields'].keyOrder:
     265                    raise ImproperlyConfigured("%s's Meta.fields contains an invalid value: %s" % (name, key))
     266            attrs['base_fields'].keyOrder = opts.fields
    260267        return type.__new__(cls, name, bases, attrs)
    261268
    262269class BaseModelForm(BaseForm):
Back to Top