ahmet
ahmet

Reputation: 347

django filter from grouped list

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

Answers (1)

Rakesh
Rakesh

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

Related Questions