prevent duplicate django code example
Example: django prevent duplicate entries
for instance in Stock.objects.all():
if instance.category == category:
raise forms.ValidationError(str(category) + ' is already created')
return category
for instance in Stock.objects.all():
if instance.category == category:
raise forms.ValidationError(str(category) + ' is already created')
return category