Search code examples
djangodjango-templatesdjango-apps

How to manage Django reusable app templates that extend common base templates?


I have a project with some components that should probably be separated out into reusable apps. However, all of the templates extend a couple of base templates for the entire site. Should I include copies of the base template in each app's template directory? What is the best way to structure template directories/inheritance?


Solution

  • For the purposes of your app, base.html or whatever the base template is called, should contain the entire HTML document so that it can function on its own. If end-users want to override the template, they can add their own copy to templates/yourappname/base.html and do whatever they want inside that file, including extend their main site template.