使用 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>