From 11c24935994ad27cca131a288fae3346f6ee0df5 Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Mon, 2 Oct 2023 20:44:26 +0200 Subject: [PATCH] document `SaveValidFormMixin` --- evap/evaluation/tools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/evap/evaluation/tools.py b/evap/evaluation/tools.py index afd575ca0e..68bb8f702b 100644 --- a/evap/evaluation/tools.py +++ b/evap/evaluation/tools.py @@ -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)