Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from apps.projects.models import Project
- from django.db.models import Count
- # Find duplicated models based on the value of one or more fields
- dupes = Project.objects.values('name').annotate(Count('id')).order_by().filter(id__count__gt=1)
- dupes = Project.objects.values('name', 'code').annotate(Count('id')).order_by().filter(id__count__gt=1)
- dupes = Project.objects.values('name', 'code', 'release').annotate(Count('id')).order_by().filter(id__count__gt=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement