Django 1.4と最新のallauthを使用すると、フォームが表示されないという奇妙な問題が発生します。
これはsettings.pyです:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'django.contrib.admin',
'django.contrib.admindocs',
'bootstrap_toolkit',
'demo_app',
'south',
)。
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
"django.core.context_processors.csrf",
"django.core.context_processors.static",
)。
これは私に問題を引き起こしているテンプレートです:password_reset.html
{% extends "account/base.html" %}
{% load i18n %}
{% load account %}
{% block head_title %}{% trans "Password Reset" %}{% endblock %}
{% block content %}
<h1>{% trans "Password Reset" %}</h1>
{% if user.is_authenticated %}
{% include "account/snippets/already_logged_in.html" %}
{% endif %}
<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}</p>
<form method="POST" action="" class="password_reset">{% csrf_token %}
{{ password_reset_form.as_p }}
<input type="submit" value="{% trans "Reset My Password" %}" />
</form>
<p>{% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %}</p>
{% endblock %}
{% block extra_body %}
<script>
$("#id_email").focus();
</script>
{% endblock %}
これは処理されない部分です:
<form method="POST" action="" class="password_reset">{% csrf_token %}
{{ password_reset_form.as_p }}
<input type="submit" value="{% trans "Reset My Password" %}" />
</form>""
また、csrf_tokenを取得しようとしましたが、取得したhtmlの結果は次のとおりです。
<form method="POST" action="">
<legend>Password reset</legend>
<p>Forgotten your password? Enter your email address below, and we'll send you an email allowing you to reset it.</p>
<fieldset>
<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='XaG5EyB6JY70kkQrsqTFnQ6wzPXujMpg' /></div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Reset my password</button>
</div>
</fieldset>
</form>
<p>If you have any trouble resetting your password, contact us at <a href="mailto:"></a>. </p>