[Answer]-Binding ModelForm to Model's instance when saving

1👍

You can do it like this:

a_form.instance = b
a_form.save()

But the Django way to modify instance before form save is to override the forms save() method. You can do it like this:

class ArticleForm(forms.ModelForm):
    ...
    def save(self):
        instance = self.instance      # Do with instance what every you want
        super(ArticleForm, self).save()
👤niekas

Leave a comment