Skip to content

Instantly share code, notes, and snippets.

@driesdesmet
Last active December 3, 2015 16:39
Show Gist options
  • Select an option

  • Save driesdesmet/511a3f2340a1f61ddf5b to your computer and use it in GitHub Desktop.

Select an option

Save driesdesmet/511a3f2340a1f61ddf5b to your computer and use it in GitHub Desktop.
Saving a Modelform subclass
class ContactForm(forms.ModelForm):
def save(self, **kwargs):
contact = super(ContactForm, self).save(kwargs)
contact.send_email()
return contact
class Meta:
model = Contact
fields = '__all__'
@driesdesmet
Copy link
Copy Markdown
Author

You forgot to unpack the dict when calling the parent class moron! You're sending an empty dict.

contact = super(ContactForm, self).save(**kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment