You can generate a variable in the view, as described above, containing your template, or you can use the template tag to create a template path for you based on another variable, i.e. phase. Register the following tag, customize it to your needs:
@register.filter def get_template_phase(template_string, phase): template_string = template_string.replace('<', '{').replace('>', '}') return template_string.format(phase=phase)
Put the above in your templatetags and register it.
Using:
{% include 'includes/home__<phase>.html'|get_template_phase:'nomination' %}
radtek
source share