Django-allauth注册,登录和社交连接到一个页面 [英] Django-allauth Sign Up, Login, and Social Connect into one page

查看:723
本文介绍了Django-allauth注册,登录和社交连接到一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用django-allauth加载社交登录,登录表单和注册表单到您的索引页面?
类似的东西,当你去facebook.com。

How do you load both the Social Login, the Login form and Sign Up form to your Index page using django-allauth? Something similar like when you go to facebook.com.

accounts / url已经在工作,我试过复制

accounts/url are already working and I've tried copying the

<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中做了一些教程。

to my index.html but it doesn't work. I'm new to Python Programming and Django development but i've done some excerise with tutorials in the Django Book.

推荐答案

处理您的索引URL并呈现您的index.html模板的视图必须具有登录表单,因为您必须将其设置为FormView后代,并将类属性设置为LoginForm(allauth的登录表单)。否则,您无法将{{form.as_p}}呈现到模板中(因为您的上下文中没有表单)。

The view that handles your 'index' url and renders your index.html template has to have a login form, for that you have to make it a FormView descendant, and set the class attribute to LoginForm (allauth's login form). Otherwise, you can't render {{form.as_p}} to the template (because there is no form in your context).

这篇关于Django-allauth注册,登录和社交连接到一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆