

def save(self, commit=True):
    super(ServiceForm, self).save(commit=False)

    def save_m2m():
        opts = self.instance._meta
        cleaned_data = self.cleaned_data
        fields = self._meta.fields
        for f in opts.many_to_many:
            if (fields and (f.name not in fields)):
                continue
            if (f.name in cleaned_data):
                if (f.name == 'depends_on'):
                    self.instance.depends_on.clear()
                    for service in cleaned_data[f.name]:
                        Dependency.objects.get_or_create(dependant=self.instance, provider=service)
                else:
                    f.save_form_data(self.instance, cleaned_data[f.name])
    if commit:
        self.instance.save()
        save_m2m()
    return commit.instance

dataset/ETHPy150Open mozilla/inventory/core/service/forms.py ServiceForm.save/VarMisuse@192/229 `self`->`commit`