Django-allauth Sign Up, Login, and Social Connect into one page

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:11:21

问题


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

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.


回答1:


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).



来源:https://stackoverflow.com/questions/18695761/django-allauth-sign-up-login-and-social-connect-into-one-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!