[Answered ]-Filter queryset for multiple models in Django

1👍

yes, it’s possible without for loop.Just follow the following script:

postinlang_queryset = PostInLanguages.objects.filter(description__contains=search_name)
media_type_query_set = LanguageMedia.objects.filter(content_type__in=['mp4','mkv','mov','avi'])

N.B: content_type__in=['mp4','mkv','mov','avi'] If we pass an empty list then it will never throw exceptions but return empty queryset

Leave a comment