Ticket #8620: django_model_forms_excluding_fields_fix.diff

File django_model_forms_excluding_fields_fix.diff, 742 bytes (added by marcinnowak, 6 years ago)

Better patch

  • forms/models.py

     
    201201                                      opts.exclude, formfield_callback)
    202202            # Override default model fields with any custom declared ones
    203203            # (plus, include all the other declared fields).
     204            if opts.fields:
     205                [declared_fields.pop(f) for f in declared_fields.keys() if f not in opts.fields]
     206            if opts.exclude:
     207                [declared_fields.pop(f) for f in declared_fields.keys() if f in opts.exclude]
    204208            fields.update(declared_fields)
    205209        else:
    206210            fields = declared_fields
Back to Top