-
Notifications
You must be signed in to change notification settings - Fork 57
Description
There is a straight self.cleaned_data = self.clean() assignment in is_valid() here: https://github.com/fusionbox/django-betterforms/blob/2.0.0/betterforms/multiform.py#L103
However, the docs allow for clean() functions to not return anything, in which case the existing .cleaned_data should be used: https://docs.djangoproject.com/en/4.2/ref/forms/validation/
The call to super().clean() in the example code ensures that any validation logic in parent classes is maintained. If your form inherits another that doesn’t return a cleaned_data dictionary in its clean() method (doing so is optional), then don’t assign cleaned_data to the result of the super() call and use self.cleaned_data instead:
def clean(self):
super().clean()
cc_myself = self.cleaned_data.get("cc_myself")
...
It looks like is_valid was originally implemented this way but was changed in 10a9c6c. Maybe this change should be partially reverted. A side note with that change, if an app does form.cleaned_data = {} the existing @cleaned_data.setter will not update any child forms, when I'd expect unreferenced forms' cleaned_data to be cleared.