email_list = Email.objects.values_list('email', flat=True).distinct()
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)
for duplicates in Tag.objects.values("name").annotate(
records=Count("name")
).filter(records__gt=1):
for tag in Tag.objects.filter(name=duplicates["name"])[1:]:
tag.delete()
for instance in Stock.objects.all():
if instance.category == category:
raise forms.ValidationError(str(category) + ' is already created')
return category
class markdownFile(models.Model):
title = models.CharField(max_length=30, unique=True)