Django-allauth加载了错误的base.html模板 [英] Django-allauth loads wrong base.html template
问题描述
该应用程式加载使用django-allauth安装的模板, $ c> base.html
文件,我用于我的网站的其余部分。
我如何告诉django-allauth在 virtualenv / lib / python2.7 / sitepackages / django-allauth中使用base.html模板
目录,而不是我的项目/模板
目录?
除非直接调用,否则您的 base.html
是您定义的模板的扩展。
例如,如果您渲染一个名为的页面 c $ c> - 在顶部您将有
{%extendsbase.html%}
。
如上定义, base.html
位于您定义的路径中在 settings.py
TEMPLATE_DIRS =()
之间 - 从您的描述中定义为 project / template
。
最好的办法是复制django-allauth base.html
文件到定义的 TEMPLATE_DIRS
位置,将其重命名为 allauthbase.html
,然后将模板扩展为一世通过 {%extendsallauthbase.html%}
,而不是默认基础。或者,您可以添加一个子文件夹到您的模板位置,如 project / template / allauth
,将allauth base.html
,然后使用 {%extendsallauth / base.html%}
。
I've been trying to get django-allauth working for a couple days now and I finally found out what was going on.
Instead of loading the base.html
template that installs with django-allauth, the app loads the base.html
file that I use for the rest of my website.
How do i tell django-allauth to use the base.html template in the virtualenv/lib/python2.7/sitepackages/django-allauth
directory instead of my project/template
directory?
Unless called directly, your base.html
is an extension of the templates that you define.
For example, if you render a template called Page.html
- at the top you will have {% extends "base.html" %}
.
When defined as above, base.html
is located in the path that you defined in your settings.py
under TEMPLATE_DIRS = ()
- which, from your description, is defined as project/template
.
Your best bet is to copy the django-allauth base.html
file to the defined TEMPLATE_DIRS
location, rename it to allauthbase.html
, then extend your templates to include it instead of your default base via {% extends "allauthbase.html" %}
.
Alternatively you could add a subfolder to your template location like project/template/allauth
, place the allauth base.html
there, and then use {% extends "allauth/base.html" %}
.
这篇关于Django-allauth加载了错误的base.html模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!