Rendering objects from two different queries in single For loop

16 views
Skip to first unread message

Bojan Drango

unread,
Mar 29, 2020, 1:10:23 PM3/29/20
to Django users

Hello.

I am trying to fetch objects from two different queries by using select_related() in order to get all of the related objects.

In template, I am using For loop in order to render all objects of first model separately, as separate containers of the data.

Inside each of these rendered objects of the first model, I need to show the corresponding data from both queries for the related second model.

The issue is that, when I am using For loop in template, I can only get the objects for the first related query, but not for the second query which is also related to the first model (basically, what second query is doing is geting all of the objects based on date less then today.)


Please check out the hastebin link below for the code - models, view and template with detailed description of the issue and the intended result and let me know if you have any hint that I may apply.


Thank you very much.
Reply all
Reply to author
Forward
0 new messages