django templates - passing variables between templates

django, django-templates, html

Solution

I found using this worked for my purposes:

page1.html:

...
{% for element in someList %}
    {% include "popup.html" with element=element %}
    <div class="col s3 some-button"><a onclick="$(showPopup('popup'));">More Info</a></div>
{% endfor %}

Problem

I have one template that includes a popup page. I loop through all values in a list that I get from the view and want to include information from each element of the list in the popup. page1.html: ``` {% include "popup.html" %} ... {% for element in someList %} <div class="col s3 some-button"><a onclick="$(showPopup('popup'));">More Info</a></div> {% endfor %} ``` showPopup is a Javascript function that will show the popup. In popup.html I reference `element` from the for loop above: popup.html ``` ... {{ element }} ... ``` But the popup.html template does not seem to be able to find the `element` from the for loop, since nothing is shown. Is there a way to make it so the popup.html is able to reference `element`?

Original source