Home > Software engineering >  Django template inheritance is not working inside the folder file. How to do?
Django template inheritance is not working inside the folder file. How to do?

Time:10-17

I am extending base.html inside the folder file. My root file name is base.html and I want to extend base.html inside the folder file.

base.html(mainfile)
-credential(foldername)
--login.html(filename)

I am trying like this

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

{% block login %} {% endblock %}

CodePudding user response:

Since the base.html is in the immediate parent folder, you have to use '..'. Try like this:

{% extends '../base.html' %}
{% block login %} {% endblock %}

CodePudding user response:

Django will check and find the base.html itself. you only have to check 2 things:

  • this is the only "base.html" into your project
  • it is saved inside a folder named "templates" into the proper project or app folder
  • Related