I had the same problem as you, since the book was written using an older
django version and there was some changes on csrf for django version
1.2. Looking at django docs
https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#how-to-use-it
you can read recommended way to use this
On 06/08/11 23:05, bob gailer wrote:
I love the django book. Until I got to the section "Tying Your First
Form Class".
Problem:-"This class can live anywhere you want — including directly
in your views.py file — but community convention is to keep Form
classes in a separate file called forms.py. Create this file in the
same directory as your views.py" The examples then use from
contact.forms import ContactForm. Where did contact come from? I had
to remove it to get the import to work!
Then all is OK until "Tying Form Objects Into Views". Here is where I
run into the
CSRF verification failed. Request aborted.
Reason given for failure: CSRF token missing or incorrect."
After much searching I found:
from django.template import RequestContext
...
form = ContactForm()
return render_to_response('contact_form.html', {'form': form},
context_instance=RequestContext(request))
and now it works.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.