Problem with django book in Forms chapter 7
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home