django-pivot icon indicating copy to clipboard operation
django-pivot copied to clipboard

Pivot on Union Queryset : Calling QuerySet.distinct() after union() is not supported.

Open Bbillyben opened this issue 3 years ago • 1 comments

Hi there,

I'm trying to get some dashboarded datas on some models, and even between models.

issue description : When I union 2 queryset of models objects, and then try to pivot with pivot_table, I've got the issue :

django.db.utils.NotSupportedError: Calling QuerySet.distinct() after union() is not supported.

Step to reproduce :

  1. define a model
  2. add some new instances
  3. : a=models.MYModel.objects.filter(pk=1) b=models.MYModel.objects.filter(pk=2) c=a.union(b) pivot_table = pivot(c, 'field1', 'field2', 'field3')

=> raise the error above

is there anything I missed ?

infos : django v4.1.2 python v3.9.2 django-pivot v1.9.0

Bbillyben avatar Oct 27 '22 09:10 Bbillyben