Override templates of external app in Django

前端 未结 2 485
忘掉有多难
忘掉有多难 2021-01-04 14:38

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.

相关标签:
2条回答
  • 2021-01-04 14:41

    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.

    0 讨论(0)
  • 2021-01-04 14:53

    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.

    0 讨论(0)
提交回复
热议问题