djangodjango-templates

Find Template in django


My code is like below.

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

I am getting error

TemplateDoesNotExist at /dashboard/

/hospital/templates/header.html

How to include a template ?


Solution

  • It is not a full path, but relative to the DIRS [Django-doc] and templates/ directory in the apps, if you enable APP_DIRS [Django-doc], so likely:

    {% include "header.html" %}