Ticket #25679: 25679.diff

File 25679.diff, 990 bytes (added by Hasan Ramezani, 9 years ago)
  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index 938535b..08f4600 100644
    a b class ModelFormMetaclass(DeclarativeFieldsMetaclass):  
    257257                raise FieldError(message)
    258258            # Override default model fields with any custom declared ones
    259259            # (plus, include all the other declared fields).
    260             fields.update(new_class.declared_fields)
     260            declare_field_list = []
     261            for declare_field in new_class.declared_fields.items():
     262                if opts.fields is not None and declare_field[0] not in opts.fields:
     263                    continue
     264                if opts.exclude and declare_field[0] in opts.exclude:
     265                    continue
     266                declare_field_list.append(declare_field)
     267            if declare_field_list:
     268                fields.update(declare_field_list)
    261269        else:
    262270            fields = new_class.declared_fields
    263271
Back to Top