postgresql - Django: Return all Values even if filtering through a related model -
Thanks for some great help on the previous question, I put my query together. Everything works an issue safely.
careers = career.obages.filter (job __bar = 1) =. Anotate (dwarves_in_career = calculation ('Job _ dwarf'))
In my opinion this is what I want and when I like it in my template loop:
{% return to career in career%} gt; {{Career.name}}: {{Career.dwarves_in_career}} & lt; / Li & gt; {% Endfor%}
I got what I expected, my point is that the above code will only return to the careers who have dwarves all careers Need to return:
Assigned: 1 Construction: 1 Crafting: 2 deposits: 0 Farming: 0
My desired result is instead The last two lines are not because I'm filtering for a specific user. I know why this is happening, what I am trying to find, how does he ask all the careers to return, even if the dwarf count for a particular user is 0.
I think you should give your annotated
and filters segments. See - you have this method, it filters queries , but you really want to keep the entire query, but only filter annotation .
Comments
Post a Comment