【问题标题】:Django AllAuth Customized Templates Not Being RecognizedDjango AllAuth 自定义模板无法识别
【发布时间】:2013-12-27 08:09:07
【问题描述】:

我在自定义 Django-Allauth 模板时遇到了问题。可能是我的 TEMPLATE_DIRS 值的问题,或者我不知道的问题。如果我将 TEMPLATE_DIRS 指向项目目录中的“Templates/AllAuth”文件夹,它会忽略我的自定义模板。现在,它忽略了我当前的 base.html 文件和我当前的 signup.html/login.html 文件,即使报告说错误来自正确的文件/文件夹。我该如何解决这个问题?

Unclosed tag 'block'. Looking for one of: endblock 

我当前的基本模板:

{% block content %}
{% endblock %}

错误出现在我的 signup.html 页面上,如下所示:

{% load staticfiles %}

{% load url from future %}
{% load i18n %}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% trans "Sign Up" %}</title>
<link rel="stylesheet" type="text/css" href="{% static "stylesheets/sign-up.css" %}" />
<link href="http://fonts.googleapis.com/css?family=Arvo:400,700|Open+Sans" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="logo">
        <img id="logo" src="{% static "media/mobile-logo.gif" %}" />
    </div>
    <div class="wrapper">
        <div class="omni-box">
            <p>Create Your My_APP Account</p>
        </div>
        <div class="sign-up-form">
            <form id="sign-up" method="post" action="{% url 'account_signup' %}">
                {% csrf_token %}
                {{ form.as_p }}
                <input type="submit" value="Sign Up!" />
            </form>
            <h3>OR</h3>
            <p class="facebook"><img class="social-button" src="{% static "media/facebook.png" %}" />Connect With Facebook</p>
            <p class="twitter"><img class="social-button" src="{% static "media/twitter.png" %} />Connect With Twitter</p>
        </div>
</div>
</body>
</html>

我的模板设置:

TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
 'django.template.loaders.app_directories.Loader')

TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates','allauth'))

在我的模板/allauth/account 文件夹中,我拥有所有自定义的模板文件。该文件夹在我的项目目录中。

【问题讨论】:

    标签: python django templates overriding django-allauth


    【解决方案1】:

    可能有点晚了,但我通过在 settings.py 中更改应用程序的顺序解决了这个问题。您必须将 allauth 放在模板所在的应用程序之后。

    【讨论】:

    • 多年后,这帮助我解决了我的问题。谢谢
    【解决方案2】:

    您应该将模板文件放在templates/account 下而不是templates/allauth/account 下。

    【讨论】:

    • 这对我不起作用;仍然不清楚什么是有效的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-01
    • 2014-08-30
    • 2015-10-13
    • 2021-10-31
    • 1970-01-01
    相关资源
    最近更新 更多