Search code examples
pythondjangomodels

how to filter a django queryset where the conditions are taken from another list?


I have a situation where i have a list of primary keys. And i need to filter(OR) a queryset using the primarykeys in the list.

But the problem is that the list is dynamic.

Is there any way i can filter the queryset by doing an OR using each primary keys on the queryset.


Solution

  • Maybe in will help https://docs.djangoproject.com/en/dev/ref/models/querysets/#in