django query id in list code example
Example 1: django filter in list
Blog.objects.filter(pk__in=[1, 4, 7])
Example 2: get a list of ids from queryset django
author = Blog.objects.filter(author=author)
ids = author.values_list('pk', flat=True)
# list method get ids without parse the returning queryset
print(list(ids))
Example 3: django queryset filter queryset using list of items
Blog.objects.filter(pk__in=[1, 4, 7])