Filter Queryset based on second column having comma seperated values

I have a queryset output:

<QuerySet [('Subject1', ['14', '20']), ('Subject2', ['14']), ('subject3', ['1','2']), ('subject4', ['1'])]>

I need to filter the above query set with second column matching with certain numbers.

For example, I need to get only those subjects where '1' are there:

Filtered Queryset: <QuerySet [('subject3', ['1','2']), ('subject4', ['1'])]>

When I use icontains or contains I end up getting matching items even with one number. But I want to get all items that only contains '1' in their second column not '14' etc.

Back to Top