Python 无法识别Django AllAuth自定义模板
我在定制Django Allauth模板时遇到了麻烦。可能是我的TEMPLATE_DIRS值有问题,或者是我不知道的问题。如果我将模板目录指向项目目录中的“Templates/AllAuth”文件夹,它将忽略自定义模板。现在,它忽略了我当前的base.html文件和我当前的signup.html/login.html文件,尽管报告说错误来自正确的文件/文件夹。我怎样才能解决这个问题Python 无法识别Django AllAuth自定义模板,python,django,templates,overriding,django-allauth,Python,Django,Templates,Overriding,Django Allauth,我在定制Django Allauth模板时遇到了麻烦。可能是我的TEMPLATE_DIRS值有问题,或者是我不知道的问题。如果我将模板目录指向项目目录中的“Templates/AllAuth”文件夹,它将忽略自定义模板。现在,它忽略了我当前的base.html文件和我当前的signup.html/login.html文件,尽管报告说错误来自正确的文件/文件夹。我怎样才能解决这个问题 Unclosed tag 'block'. Looking for one of: endblock 我当前的
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>
在我的templates/allauth/account文件夹中,我有我定制的所有模板文件。该文件夹位于我的项目目录中。您应该将模板文件放在
模板/account
下,而不是模板/allauth/account下。可能有点晚了,但我通过在settings.py中更改应用程序的顺序解决了这个问题。你必须将allauth放在模板所在的应用程序之后。这对我不起作用;仍然不清楚什么起作用。许多年后,这帮助我解决了我的问题。非常感谢。
TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader')
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates','allauth'))