Home > Back-end >  Use HTML-template from other app, in same project (Django)
Use HTML-template from other app, in same project (Django)

Time:01-19

I have a project wich contains two apps User and Accounting. Since all of their HTML-templates should extend from the same base.html template, I made a third app called Shared, and my accounting/base.html and user/base.html would then extend from shared/base.html like

{% extends "shared/base.html" %}


{% block content %}
<div>Hello world</div>

{% endblock content %}

but that does not work, since Django looks in <app>/templates/shared/base.html.

Can this be done without having to just duplicate base.html and have the same file in Accounting and User?

CodePudding user response:

You need to have all apps in INSTALLED_APPS for such template lookups.

Otherwise Django does not know that is supposed to look in templates folder inside shared app.

  • Related