80
Perhaps…
filter_dict = {'subcat__id__in': [1,3,5]}
Listing.objects.filter(**filter_dict)
- [Django]-What is the best AJAX library for Django?
- [Django]-Django custom command not found
- [Django]-Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of:
1
You can do an OR query like this:
from functools import reduce
from operator import or_
query_as_dict = {"subcat__id__in": [1,3,5], "cat__id": 9}
query = reduce(or_, (Q(**{key: value}) for key, value in query_as_dict.items()))
Listing.objects.filter(query)
- [Django]-Django 1.9 ImportError for import_module
- [Django]-How do I integrate Ajax with Django applications?
- [Django]-How do I get the object if it exists, or None if it does not exist in Django?
Source:stackexchange.com