FormSet.forms is an iterable, so just iterate over it
This commit is contained in:
parent
51739c6241
commit
b79aa796d8
|
@ -247,8 +247,7 @@ is where you define your own validation that works at the formset level::
|
||||||
... # Don't bother validating the formset unless each form is valid on its own
|
... # Don't bother validating the formset unless each form is valid on its own
|
||||||
... return
|
... return
|
||||||
... titles = []
|
... titles = []
|
||||||
... for i in range(0, self.total_form_count()):
|
... for form in self.forms:
|
||||||
... form = self.forms[i]
|
|
||||||
... title = form.cleaned_data['title']
|
... title = form.cleaned_data['title']
|
||||||
... if title in titles:
|
... if title in titles:
|
||||||
... raise forms.ValidationError("Articles in a set must have distinct titles.")
|
... raise forms.ValidationError("Articles in a set must have distinct titles.")
|
||||||
|
|
Loading…
Reference in New Issue