Closed AsheKR closed 4 years ago
In your viewset just add:
def get_queryset(self):
return self.queryset.distinct()
And if you're using postgresql you must precede distinct by order-by, using same field, like this:
queryset = YourObject.objects.all().order_by( 'pk').distinct('pk')
Hi @AsheKR. The current workaround as others have stated is to provide an already distinct base queryset to your filterset. However, in the upcoming 1.0.0.dev1
release, RelatedFilter
will now obey the distinct
argument like other filters.
Fixed by #342.
/api/posts/?comment__content='some contnet'
has more than one same post idhow can i distinct this result?