12

I want to override the templates of an external app (allauth, installed in site packages). Unfortunately no advice i read worked. I added the following to my settings.py:

PROJECT_ROOT = os.path.normpath(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates', 'allauth'))

and copied all templates (this content) to my_project_dir/templates/allauth. But when I restart the server and reload the page I only get the rendered templates from the original allauth app in site packages, not mine custom templates. Any hints?

medihack
  • 16,045
  • 21
  • 90
  • 134

2 Answers2

36

Check the INSTALLED_APPS order, the first template matched will be rendered.

With this in mind you can just add the template under the same path in a custom app.

ulysses
  • 639
  • 7
  • 6
9

The way I tend to figure out what's going on (with DEBUG set to True), is to have a view render a template that didn't exist, and look at the list of locations Django tried to load templates from (which will be included in the error page output).

What templates are the views trying to render? If they're trying to render allauth/foo.html, then you'll want to add my_project_dir/templates to your TEMPLATE_DIRS setting, not my_project_dir/templates/allauth.

Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212