In Django, how to find rows which would violate a unique together constraint?
I managed to group the duplicate UserApn
s into the following queryset:
UserApn.objects.all().difference(UserApn.objects.distinct('user', 'player_id'))
Note that passing multiple arguments to distinct()
only works on PostgreSQL.