File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,23 @@ def test_always_tree_query(self):
391391 assert obj .name == "Something"
392392 AlwaysTreeQueryModel .objects .all ().delete ()
393393
394+ def test_tree_query_select_related (self ):
395+ AlwaysTreeQueryModel .objects .create (
396+ name = "Nothing" , category = AlwaysTreeQueryModelCategory .objects .create ()
397+ )
398+ AlwaysTreeQueryModel .objects .create (
399+ name = "Nothing" , category = AlwaysTreeQueryModelCategory .objects .create ()
400+ )
401+
402+ tc = TestCase ()
403+ with tc .assertNumQueries (1 ):
404+ _read = [
405+ (obj , obj .category )
406+ for obj in AlwaysTreeQueryModel .objects .with_tree_fields ().select_related (
407+ "category"
408+ )
409+ ]
410+
394411 def test_always_tree_query_relations (self ):
395412 c = AlwaysTreeQueryModelCategory .objects .create ()
396413
You can’t perform that action at this time.
0 commit comments