Created
September 23, 2020 10:56
-
-
Save gemcave/bd09f56778623d3bd9df99e4f7014ac1 to your computer and use it in GitHub Desktop.
django-extra-views save formset
This file contains 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
def forms_valid(self, form, inlines): #yes, f%%ng form(s)_valid, yeh... | |
""" | |
If the form and formsets are valid, save the associated models. | |
""" | |
self.object = form.save(commit=False) | |
self.object.author = self.request.user | |
form.save(commit=True) | |
for formset in inlines: | |
formset.save() | |
return HttpResponseRedirect(self.get_success_url()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment