Skip to content

Instantly share code, notes, and snippets.

@gemcave
Created September 23, 2020 10:56
Show Gist options
  • Save gemcave/bd09f56778623d3bd9df99e4f7014ac1 to your computer and use it in GitHub Desktop.
Save gemcave/bd09f56778623d3bd9df99e4f7014ac1 to your computer and use it in GitHub Desktop.
django-extra-views save formset
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