Last active
December 3, 2015 16:39
-
-
Save driesdesmet/511a3f2340a1f61ddf5b to your computer and use it in GitHub Desktop.
Saving a Modelform subclass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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__' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You forgot to unpack the dict when calling the parent class moron! You're sending an empty dict.
contact = super(ContactForm, self).save(**kwargs)