Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use HTML-template from other app, in same project (Django)

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading