Answers for "django model remove duplicates"

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

django model remove duplicates

from django.db.models import Count
from app.models import Email

duplicate_emails = Email.objects.values('email').annotate(email_count=Count('email')).filter(email_count__gt=1)
Posted by: Guest on September-14-2021

Python Answers by Framework

Browse Popular Code Answers by Language