I have 2 tables:
Table1: [A-Foriegn Key, field1]
Table2: [Table1-Foriegn Key, field2]
I want to display a list with distinct values of Table1 field1 if items are present in Table2. and inside that list I want to display all the elements of Table2 corresponding to that field1 of Table1.
I am trying :
{% for t1 in Table1 %}
Display field1 of t1
{% for t2 in Table2 %}
Display field2 of t2.
{% endfor %}
{% endfor %}
Table 1:
╔════╦══════════════╦══════╗
║ Id ║ EventName ║ FK ║
╠════╬══════════════╬══════╣
║ 1 ║ Christmas ║ 56 ║
║ 2 ║ Black Friday ║ 18 ║
╚════╩══════════════╩══════╝
Table 2:
╔════╦══════════════╦══════╗
║ ID ║ Image ║ FK ║
╠════╬══════════════╬══════╣
║ 1 ║ image1_url ║ 1 ║
║ 2 ║ image2_url ║ 1 ║
║ 3 ║ image3_url ║ 2 ║
║ 4 ║ image4_url ║ 2 ║
╚════╩══════════════╩══════╝
I want to display : Christmas and BlackFriday in a list.
And on clicking element from the list, I want to display all url for that particular event. Like on clicking Christmas: image1_url and image2_url should be displayed.
I dont want to make AJAX requests.