Search code examples
djangodjango-templatesreusability

Base Template in reusable Django App


I want create a reusable app from a custom project.

The part I want to move to a reusable app serves whole pages and uses this at the top:

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

Now I am unsure what base template to use. In the new reusable app, I don't want to use myproject since this is custom code which I can't share.

I tried to get help from the great django docs, but could not find a solution - Forgive me if I was blind :-)

What to write here in a reusable app?

{% extends ??????? %}


Solution

  • You need to store those templates within the app folder.

    Assuming you have a structure like myproject/myreusableapp you would create a templates folder inside myreusableapp folder and store your base.html file there.

    You would then extend that file {% extends "myreusableapp/base.html" %}