title: Django Include Template based on Context
body: <p>I was wondering if there is a way of including a variable in an include statement in a Django template. For example if you have a for loop over a set of objects and you want to load only templates related to those objects (example bellow).</p>
  
  <pre><code>{% for app in apps %}
  &lt;div class="modal fade hidden" id="myModal_{{ app.id }}"&gt;
    &lt;div class="modal-header"&gt;
      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
      &lt;h3 id="myModalLabel"&gt;Add {{ app.title }}&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div class="modal-body"&gt;
      &lt;form class="bs-docs-example form-horizontal"&gt;
  
  
        {% include "app_templates/{{ app.title }}/modal-config.html" %}
  
  
      &lt;/form&gt;
    &lt;/div&gt;
    &lt;div class="modal-footer"&gt;
      &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
      &lt;button class="add-app-btn btn btn-primary" data-appid="{{ app.id }}"&gt;Add&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>Or is there a better way of doing this. Thanks.</p>