How to convert a list in to queryset django

前端 未结 4 654
盖世英雄少女心
盖世英雄少女心 2021-02-04 09:27

I have a queryset(which is filtered actually) as below

posts = [, , , , 

        
4条回答
  •  离开以前
    2021-02-04 09:54

    You can query the Tag object first and filter Post with those ids:

    tags = Tag.objects.filter(field_name='string_or_field')
    posts = Post.objects.filter(tags__in=tags)
    

提交回复
热议问题