Django query where in

后端 未结 3 1459
温柔的废话
温柔的废话 2021-01-31 17:02

How to do this using django object query:

 SELECT * FROM test WHERE (test_id IN (SELECT test_id FROM test_subject_set)) AND (test_begin_time < \'\') AND (test         


        
3条回答
  •  我在风中等你
    2021-01-31 17:49

    Two querysets is documented way of doing this. It will be one database hit anyway.

    test_ids = Subject.objects.all()
    result = Test.objects.filter(test_id__in=test_ids).filter([some other filtering])
    

提交回复
热议问题