Ticket #12337: forms_save_m2m_exclude2.diff

File forms_save_m2m_exclude2.diff, 928 bytes (added by Stephen Burrows, 13 years ago)

I've adjusted the patch slightly to also actually *pass* the exclude value from the form's Meta to the save_instance function.

  • django/forms/models.py

    diff --git a/django/forms/models.py b/django/forms/models.py
    index cd8f027..02c09d2 100644
    a b def save_instance(form, instance, fields=None, fail_message='saved',  
    7979        for f in opts.many_to_many:
    8080            if fields and f.name not in fields:
    8181                continue
     82            if exclude and f.name in exclude:
     83                continue
    8284            if f.name in cleaned_data:
    8385                f.save_form_data(instance, cleaned_data[f.name])
    8486    if commit:
    class BaseModelForm(BaseForm):  
    361363        else:
    362364            fail_message = 'changed'
    363365        return save_instance(self, self.instance, self._meta.fields,
    364                              fail_message, commit, construct=False)
     366                             fail_message, commit, self._meta.exclude,
     367                             False)
    365368
    366369    save.alters_data = True
    367370
Back to Top