13

I am trying to follow Django's Template system while using a base.html file, however I am unsure of where to place base.html inside of my project. With namespacing in mind, Django suggests that your templates go inside of your 'project_name/app_name/templates/app_name/' directory. Since I would like to extend my base.html in multiple apps in my project, where should my base.html reside?

Jimi
  • 141
  • 1
  • 5

1 Answers1

17

Since this is a shared template, place it in the project's templates directory:

project_name/templates/base.html

Also see:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Receiving a "TemplateDoesNotExist at /news/" when trying to extend base.html. I have updated my TEMPLATE_DIRS setting to include "/project_name/templates" and "/news/templates". My template loader postmordem states /project_name/templates/base.html (File does not exist) /news/templates/base.html (File does not exist). I feel like I missed a step but can't seem to figure it out. Do you have any suggestions on what I may have done wrong? Do I have to adjust my "extends" statement at all? – Jimi Sep 12 '14 at 15:03
  • 2
    @Jimi add the absolute path to the `templates` directory to the `TEMPLATE_DIRS` setting, then use just `{% extends 'base.html' %}`. Should work. – alecxe Sep 12 '14 at 15:21
  • 1
    I don't have enough rep to vote your answer but thank you so much for the prompt assistance. Absolute paths resolved the error I was receiving. – Jimi Sep 13 '14 at 13:45