0

Django Union always worked but i got a strange situation where its not work properly.

I have tried to get union of some queryset but got strange result.

I have also check with How can I find the union of two Django querysets? but its not working as well.

Here i have attached image to show my tries.

enter image description here

in the above image i get four queryset( qs, qs1 , qs2, my_qs ) after filter BetDetails model here i want to get result in my_qs
And when i tried to merge/Union of the queryset got on blank queryset in my_qs While i have data in qs1 . expected result should be

  <QuerySet [<BetDeetails: BetDetails object (29)>]>

But i got :

   <QuerySet []>

model:

class BetDetails(DefaultFieldsModel):
    name = models.CharField(max_length=20)
    type = models.CharField(max_length=20)
    status = models.CharField(max_length=10)

I don't know why its showing this type of result. Can anyone please explain and guide me to get desired result.

Somil
  • 1,921
  • 1
  • 21
  • 35
  • Do the `qs` query the same model? – Willem Van Onsem Sep 12 '19 at 14:57
  • Yes, i am getting all querysets after filter BetDetails model. – Somil Sep 12 '19 at 16:08
  • Please provide the models for the querysets, and see [*Why should I provide a minimal, reproducible example for a very simple sql query?*](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query) – Lord Elrond Sep 12 '19 at 18:36
  • @CalebGoodman question is updated with model details. – Somil Sep 13 '19 at 10:05
  • is `DefaultFieldsModel` a third party package? I am not familiar with it. Also, what model are you trying to Union with? – Lord Elrond Sep 13 '19 at 18:55
  • @CalebGoodman No, its is simple model created by me where i added some defaluts model field like created date, updated date , status etc. and i am trying to union BetDetails model's queryset. – Somil Sep 14 '19 at 13:30

0 Answers0