Find Template

My code is like below.

{% if request.path != '/login/' %}
      {% include "/hospital/templates/header.html" %}   
{% endif %}

I am getting error

TemplateDoesNotExist at /dashboard/


How to include a template ?

First, you shouldn’t have the leading “/” in the path for the include. You most likely don’t (or won’t) have a “hospital” directory in your root. See the docs and examples for the include tag.

Relative to your “BASE_DIR”, what directory does this header.html file reside in? (Is this “hospital” directory your project directory or an app directory?)

Do you have 'APP_DIRS' : True in your TEMPLATES setting?

1 Like