Django inlineformset check for duplicates
class InlineFormSet(forms.BaseFormSet):
def clean(self):
if any(self.errors):
return
values = set()
for form in self.forms:
data = form.cleaned_data
if data in values:
raise forms.ValidationError(
'Duplicate values for "%s" are not allowed.' % data)
values.add(data)