1
0
mirror of https://github.com/django/django.git synced 2025-04-18 06:14:37 +00:00

[2.2.x] Fixed -- Fixed custom formset validation example in docs.

Backport of d610521bffe9d44a070ebe3a719b474aff6d3d1e from master
This commit is contained in:
Tobias Kunze 2019-04-16 09:24:48 +02:00 committed by Mariusz Felisiak
parent 0ba78c3989
commit c0dc49a772

@ -274,7 +274,9 @@ is where you define your own validation that works at the formset level::
... return
... titles = []
... for form in self.forms:
... title = form.cleaned_data['title']
... if self.can_delete and self._should_delete_form(form):
... continue
... title = form.cleaned_data.get('title')
... if title in titles:
... raise forms.ValidationError("Articles in a set must have distinct titles.")
... titles.append(title)