How to concatenate strings in django templates

djangodjango-templates

I want to concatenate a string in a Django template tag, like:

{% extend shop/shop_name/base.html %}

Here shop_name is my variable and I want to concatenate this with rest of path.

Suppose I have shop_name=example.com and I want result to extend shop/example.com/base.html.

Best Answer

Use with:

{% with "shop/"|add:shop_name|add:"/base.html" as template %}
{% include template %}
{% endwith %}