Fixes #11032 - Replication fields broken in custom validation

This commit is contained in:
kkthxbye-code 2023-02-08 12:08:00 +01:00
parent 56c7a238a4
commit a1ff3800c7
2 changed files with 8 additions and 0 deletions

View File

@ -257,6 +257,10 @@ class CustomValidationMixin(models.Model):
def clean(self):
super().clean()
# If the instance is a base for replications, skip custom validation
if hasattr(self, '_replicated_base'):
return
# Send the post_clean signal
post_clean.send(sender=self.__class__, instance=self)

View File

@ -436,6 +436,10 @@ class ComponentCreateView(GetReturnURLMixin, BaseObjectView):
form = self.initialize_form(request)
instance = self.alter_object(self.queryset.model(), request)
# Note that the form instance is a replicated field base
# This is needed to avoid running custom validators multiple times
form.instance._replicated_base = hasattr(self.form, "replication_fields")
if form.is_valid():
new_components = []
data = deepcopy(request.POST)