如何使用django-allauth将社交登录,登录表单和注册表单加载到索引页面? 类似于去facebook.com的时候。
accounts / url已经有效了,我试过复制
<form class="login" method="POST" action="{% url 'account_login' %}">
{% csrf_token %}
{{ form.as_p }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
<button class="primaryAction" type="submit">{% trans "Sign In" %}</button>
</form>
到我的index.html但它不起作用。 我是Python编程和Django开发的新手,但我已经在Django Book中做了一些教程。
答案 0 :(得分:0)
处理您的索引的视图&#39; url并呈现你的index.html模板必须有一个登录表单,因为你必须使它成为一个FormView后代,并将class属性设置为LoginForm(allauth的登录表单)。否则,您无法将{{form.as_p}}呈现给模板(因为您的上下文中没有表单)。