From 1bf43df33dda231daab66451a7efcbc6c68304ae Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 20 May 2007 20:39:32 +0000 Subject: [PATCH] Edited docs/newforms.txt changes from [5294] and [5295] git-svn-id: http://code.djangoproject.com/svn/django/trunk@5298 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/newforms.txt | 125 +++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 73 deletions(-) diff --git a/docs/newforms.txt b/docs/newforms.txt index a94cc665c5..aaabebe5ce 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -313,33 +313,6 @@ record, here's what happens with unbound forms:: ... AttributeError: 'ContactForm' object has no attribute 'cleaned_data' - -Example View -~~~~~~~~~~~~ - -Putting this all together, here is a simple view method that uses our contact -form:: - - from django.shortcuts import render_to_response - from django.http import HttpResponseRedirect - from django import newforms as forms - - class ContactForm(forms.Form): - subject = forms.CharField(max_length=100) - message = forms.CharField() - sender = forms.EmailField() - cc_myself = forms.BooleanField() - - def contact(request): - if request.POST: - f = ContactForm(request.POST) - if f.is_valid: - # ... do something with f.cleaned_data - return HttpResponseRedirect('/url/on_success/') - else: - f = ContactForm() - return render_to_response('contact.html', {'form': f}) - Outputting forms as HTML ------------------------ @@ -416,12 +389,6 @@ containing one field::

-In a template, you can invoke this if the form has been handed into the -context. For example:: - - {{ f.as_p }} - - ``as_ul()`` ~~~~~~~~~~~ @@ -438,11 +405,6 @@ so that you can specify any HTML attributes on the ``