1for instance in Stock.objects.all():
2 if instance.category == category:
3 raise forms.ValidationError(str(category) + ' is already created')
4 return category
1if not table.objects.filter(column1=values).exists():
2 # Insert new data here
3 table.objects.create(column1=v1, column2=v2)