开发者

Login and registration form on one page with Django

I have been stuck on this for a while. I am trying to put both the login and registration forms on the same page, however I have been getting multiple errors depending on which approach I try. The page is actually able to load fine, however neither of the form fields will load. And then when I hit the register or login button (both type submit), I most recently am gettin开发者_开发百科g a csrf related error. Any suggestions on how to implement both forms on the same page would be greatly appreciated.


I think it might be csrf token not found error.If you are using django 1.3 with csrf middleware you have to put csrf token {% csrf_token %} tag with each form posting data like this:

{% extends "admin/base.html" %}
{% load i18n %}

{% block content %}
<form method="post" action=".">{% csrf_token %}

  {{ form.as_p }}

  <input type="submit" value="{% trans 'Submit' %}" />
</form>
{% endblock %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜