Django AllAuth 自定义模板无法识别

use*_*860 2 python django templates overriding django-allauth

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

Unclosed tag 'block'. Looking for one of: endblock 
Run Code Online (Sandbox Code Playgroud)

我当前的基本模板:

{% block content %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)

该错误发生在我的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>
Run Code Online (Sandbox Code Playgroud)

我的模板设置:

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

TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates','allauth'))
Run Code Online (Sandbox Code Playgroud)

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

rix*_*rix 6

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