From d610521bffe9d44a070ebe3a719b474aff6d3d1e Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Tue, 16 Apr 2019 09:24:48 +0200 Subject: [PATCH] Fixed #14009 -- Fixed custom formset validation example in docs. --- docs/topics/forms/formsets.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index b9c8721bf5..ddc97db3e5 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -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)