1. add {% csrf_token %} in your form content and it will be converted into a hidden field in the form. Once you check the source code of the form you will see it.
{% extends "base.html" %}
{% block title %}Create Event - {{block.super}}{% endblock %}
{% block main_content %}
{% csrf_token %}
{{form.as_ul}}
{% endblock%}
Source cod ein the web browser:
Create Event - start the dark
2. The other way to solve the problem is: comment the following setence in your Django configure file.It solves the problem however, this is the very bad way to do it since you will lose CSRF protection by doing so.
#'django.middleware.csrf.CsrfViewMiddleware'
Source: http://joelklabo.wordpress.com/2010/06/09/more-django-csrf-token-fun/
No comments:
Post a Comment