Answers for "how to avoid inserting duplicate records in orm django"

0

django prevent duplicate entries

for instance in Stock.objects.all():
			if instance.category == category:
				raise forms.ValidationError(str(category) + ' is already created')
		return category
Posted by: Guest on February-02-2021
0

how to avoid inserting duplicate records in orm django

if not table.objects.filter(column1=values).exists():
    # Insert new data here
    table.objects.create(column1=v1, column2=v2)
Posted by: Guest on February-14-2021

Code answers related to "how to avoid inserting duplicate records in orm django"

Python Answers by Framework

Browse Popular Code Answers by Language