Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django allauth-base.html中包含的模板导致递归错误_Django_Templates_Include_Django Allauth - Fatal编程技术网

Django allauth-base.html中包含的模板导致递归错误

Django allauth-base.html中包含的模板导致递归错误,django,templates,include,django-allauth,Django,Templates,Include,Django Allauth,我正在使用allauth来处理我的所有身份验证。使用该应用程序,每个认证功能都有自己的模板。但是,我希望在所有其他模板中包含注册表。i、 e.注册表位于/account/login/,/account/password/change。。。等等 我决定通过在base.html中包含signup.html来实现这一点,base.html在所有其他模板中都进行了扩展。像这样: base.html ... <h4 class="card-title text-center">Register

我正在使用allauth来处理我的所有身份验证。使用该应用程序,每个认证功能都有自己的模板。但是,我希望在所有其他模板中包含注册表。i、 e.注册表位于/account/login/,/account/password/change。。。等等

我决定通过在base.html中包含signup.html来实现这一点,base.html在所有其他模板中都进行了扩展。像这样:

base.html

...
<h4 class="card-title text-center">Register</h4>
{% include "account/signup.html" %}
...
{% extends "base.html" %}
{% extends "account/base.html" %}

{% load i18n %}

<p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>

{% for message in messages %}
    <span style="color:red;">{{ message }}</span>
{% endfor %}

<form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
    {% csrf_token %}
    {% for field in form %}
        <div id="input-group">
            {{ field }}
        </div>
    {% endfor %}
    {% if redirect_field_value %}
        <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
    {% endif %}
    <div class="card-footer text-center">
        <input type="submit" class="btn" value='{% trans "Get started" %}'>
    </div>
</form>
{% extends "account/base.html" %}
{% load static %}
{% load i18n %}
{% load account socialaccount %}

{% get_providers as socialaccount_providers %}

{% block general_notice_modal %}
{% endblock general_notice_modal %}

{% block login-modal %}
...
account/signup.html

...
<h4 class="card-title text-center">Register</h4>
{% include "account/signup.html" %}
...
{% extends "base.html" %}
{% extends "account/base.html" %}

{% load i18n %}

<p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>

{% for message in messages %}
    <span style="color:red;">{{ message }}</span>
{% endfor %}

<form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
    {% csrf_token %}
    {% for field in form %}
        <div id="input-group">
            {{ field }}
        </div>
    {% endfor %}
    {% if redirect_field_value %}
        <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
    {% endif %}
    <div class="card-footer text-center">
        <input type="submit" class="btn" value='{% trans "Get started" %}'>
    </div>
</form>
{% extends "account/base.html" %}
{% load static %}
{% load i18n %}
{% load account socialaccount %}

{% get_providers as socialaccount_providers %}

{% block general_notice_modal %}
{% endblock general_notice_modal %}

{% block login-modal %}
...
此代码导致以下错误,仅当我在base.html中添加{%include%}标记时才会发生此错误

...
<h4 class="card-title text-center">Register</h4>
{% include "account/signup.html" %}
...
{% extends "base.html" %}
{% extends "account/base.html" %}

{% load i18n %}

<p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>

{% for message in messages %}
    <span style="color:red;">{{ message }}</span>
{% endfor %}

<form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
    {% csrf_token %}
    {% for field in form %}
        <div id="input-group">
            {{ field }}
        </div>
    {% endfor %}
    {% if redirect_field_value %}
        <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
    {% endif %}
    <div class="card-footer text-center">
        <input type="submit" class="btn" value='{% trans "Get started" %}'>
    </div>
</form>
{% extends "account/base.html" %}
{% load static %}
{% load i18n %}
{% load account socialaccount %}

{% get_providers as socialaccount_providers %}

{% block general_notice_modal %}
{% endblock general_notice_modal %}

{% block login-modal %}
...

我认为代码如下:

{% include "account/signup.html" %}
应该在“account/base.html”中,而不是在“base.html”中

您有一个错误,因为您的“base.html”调用了“account/signup.html”,而您的“account/signup.html”调用了“account/base.html”,这两个用户自称为“base.html”。你有一个循环