Reputation: 347
I have a grouped lists where I am trying to write a query filter.
Grouped list: (listname: group)
[({'swtype': 1}, ['201', '203', '205']), ({'swtype': 2}, ['207', '208'])]
I am trying to access 201,203,205 from the first group one by one.How can I do that ?
f_list = FP.objects.filter(pk__in= group[0])
I am trying the above code without success.Should I loop over ?
Upvotes: 1
Views: 45
Reputation: 82785
You have a list of tuple. The ids are second value in them use group[0][1]
or group[0][-1]
Ex:
f_list = FP.objects.filter(pk__in= group[0][1])
Upvotes: 2