简体   繁体   中英

Chain Multiple Objects into parent Object Django

I am working on an app in django and i am wondering if there is a method to chain multiple objects into 1 parent.

For example, I have -query_1-, -query_2-, and I would like to put the objects that those queries return into one -parent_object- to pass to the template, which I can access on the template side like {{ parent_object.query_1.field }}, is this possible or is there a way to achieve a similar effect ?

from itertools import chain
chained_qs = chain(qs1, qs2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM