什麼是導致以下模板錯誤?什麼導致了以下模板錯誤'無效塊標記:'blocktrans',預計'elif','else'或'endif'?
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 %}
發佈標記(模板),以及例外......這就是我們所需要的。 – Nix 2013-03-21 12:38:33
下次請自行格式化您的問題。我也想知道這是不是太本地化。 – Private 2013-03-21 12:45:47
看來,如果你在第152行它沒有關閉(基於我所看到的)。也許你應該嘗試在末尾添加{%endif%} – 2013-03-21 12:40:19