Search code examples
djangoextends

There is a way to {% extends '' %} parent html from alternative folder in template?


My project has several customers. Each app has html files that need to be specific for that customer, althogh has the same name.

My approach to solve this was a variable which holds the folder's name with customer's html files, before the template's path, with this:

{% extends {{FOLDER_NAME}}'account/form/base.html' %}

instead this:

{% extends 'account/form/base.html' %}

of-course this don't work and I was wondering if there is a way to solve this.

Thanks in advance.


Solution

  • When you are inside {% %} you should not use {{}}.

    Instead just directly use the name inside {% %} and string concat it with the rest of your url using |add: syntax.

    So in your case

    {% extends FOLDER_NAME|add:'account/form/base.html' %}
    

    will work.