how to get rid of duplicate code in 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