I am writing custom List filter and inside filter call i have a Django queryset as below
queryset =[qs1, qs2, qs3]
queryset have a attribute Count_val = 0, UUID = (unique id) for all objects in queryset
so lets say
qs1 = {uuid: 123, count_val: 0}
qs2 = {uuid: 456, count_val: 0}
qs1 = {uuid: 789, count_val: 0}
Also
I have a dictionary like {uuid: count_val}
example {123: 5, 456: 10 , 789: 15 }
I want to update queryset attribute count_values for all objects before returning queryset as response
Maybe annotate but how i pull each uuid for each value
queryset=queryset.annotate(count_val = Case(When(uuid_in=dictionary.keys(), then=dictionary[uuid]), field_type=Integer)) ## not correct syntax just an example
# inserting to new field is also fine
#queryset.extra(value={count_val : dictionary[uuid]})
return queryset
Thanks for help