gpt4 book ai didi

django - 是什么导致以下模板错误 'Invalid block tag: ' blocktrans', Expected 'elif' 、 'else' 或 'endif' ?

转载 作者:行者123 更新时间:2023-12-02 18:16:56 24 4
gpt4 key购买 nike

什么原因导致以下模板错误?

In template /var/www/userreg/tagging/templates/registration/login.html, error at line 153

Invalid block tag: 'blocktrans', expected 'elif', 'else' or 'endif'
143 :
144 :
145 : <td>
146 :
147 : </td>
148 : </tr>
149 : </table>
150 : </td>
151 : <td style="text-align:center;">
152 : {% if socialaccount.providers %}
153 : <p> {% blocktrans with site.name as site_name %} Please sign in with your
existing acounts through {% endblocktrans %}
154 :
155 : <div class="socialaccount_ballot">
156 :
157 : <ul class="socialaccount_providers">
158 : {% include "socialaccount/snippets/provider_list.html" %}
159 : </ul>
160 :
161 : <div class="login-or">{% trans 'or' %}</div>
162 :
163 : </div>
Exception Type: TemplateSyntaxError at /accounts/login/
Exception Value: Invalid block tag: 'blocktrans', expected 'elif', 'else' or 'endif'

环境:

Request Method: GET
Django Version: 1.5
Python Version: 2.7.3

已安装的应用程序:

 ('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'registration',
'django.contrib.humanize',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin')

安装的中间件:

 ('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

我的模板

{% extends "base.html" %}

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

{% block title %}Log in{% endblock %}

{% block content_header %}Log in{% endblock %}

{% block main_content %}
{% if socialaccount.providers %}
<p>
{% blocktrans with site.name as site_name %}
Please sign in with your existing acounts through
{% endblocktrans %}

<div class="socialaccount_ballot">
<ul class="socialaccount_providers">
{% include "socialaccount/snippets/provider_list.html" %}
</ul>

<div class="login-or">{% trans 'or' %}</div>
</div>

{% include "socialaccount/snippets/login_extra.html" %}

{% blocktrans %}
<a href="{{ signup_url }}">sign up</a> for a {{site_name}} account and sign in below:
{% endblocktrans %}
</p>
{% endif %}
{% endblock %}

最佳答案

您定义的site_name位于:

{% blocktrans with site.name as site_name %}
Please sign in with your existing acounts
{% endblocktrans %}

你没有引用它的地方。

但是您在以下位置引用了 site_name:

{% blocktrans %}
<a href="{{ signup_url }}">sign up</a> for a {{site_name}} account and sign in below:
{% endblocktrans %}

您没有在打开 blocktrans 标记时声明和定义 site_name

正如我从您的回溯中看到的,django 没有提示,因此错误可能是从 socialaccount/snippets/provider_list.htmlsocialaccount/snippets/login_extra.html 发出的>.

关于django - 是什么导致以下模板错误 'Invalid block tag: ' blocktrans', Expected 'elif' 、 'else' 或 'endif' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15547749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com