Django inlineformset check for duplicates

Django -- Posted on July 17, 2017

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)
                  
   
            

Related Posts