Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. from apps.projects.models import Project
  2. from django.db.models import Count
  3.  
  4. # Find duplicated models based on the value of one or more fields
  5.  
  6. dupes = Project.objects.values('name').annotate(Count('id')).order_by().filter(id__count__gt=1)
  7. dupes = Project.objects.values('name', 'code').annotate(Count('id')).order_by().filter(id__count__gt=1)
  8. 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