In Django, how to find rows which would violate a unique together constraint? In Django, how to find rows which would violate a unique together constraint? database database

In Django, how to find rows which would violate a unique together constraint?


I managed to group the duplicate UserApns 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.