Skip to content

Commit

Permalink
document SaveValidFormMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin committed Oct 2, 2023
1 parent 73a5d22 commit 11c2493
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions evap/evaluation/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def formset_valid(self, formset):


class SaveValidFormMixin:
"""
Call `form.save()` if the submitted form is valid.
Django's `ModelFormMixin` (which inherits from `SingleObjectMixin`) does the same, but cannot always be used, for
example if a formset for a collection of objects is submitted.
"""

def form_valid(self, form):
form.save()
return super().form_valid(form)
Expand Down

0 comments on commit 11c2493

Please sign in to comment.