[Answer]-Django Include Template based on Context

1👍

You can do it like this:

{% with template_name="app_templates/"|add:app.title|add:"/modal-config.html" %}
    {% include template_name %}
{% endwith %}

I’m not sure maybe this would even work:

{% include "app_templates/"|add:app.title|add:"/modal-config.html" %}.

But in that case I’d rather make a template tag or filter to encapsulate this logic away from the template.

👤jpic

Leave a comment