Search code examples
pythondjangodjango-templatesinclude-path

What's the correct include path in this template?


I am editing file:

/templates/account/base.html

and in it want to include:

/templates/profiles/includes/sub_nav.html

I have tried the following:

{% block subnav %}{% include "profiles/includes/sub_nav.html"%}{% endblock %}

result: no error but no inclusion of side bar

and I have also tried

{% block subnav %}{% include "../profiles/includes/sub_nav.html"%}{% endblock %}

result: Template error page: Exception Value: Caught TemplateDoesNotExist while rendering: ../profiles/includes/sub_nav.html

with following line highlighted: {% extends "account/base.html" %}

Thus, for below, what should XXX be as contained /templates/account/base.html?

{% block subnav %}{% include "XXX/sub_nav.html"%}{% endblock %}

Solution

  • "result: no error but no inclusion of side bar".

    Logical conclusion

    Your sub_nav.html has problems. Or your base.html has problem The include is working. It must be the HTML, CSS or Django Tags.