#23904: Forms Overview
-------------------------------+--------------------
     Reporter:  Brett55        |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.7
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 On the forms overview, the views.py snippet:
 https://docs.djangoproject.com/en/1.7/topics/forms/

 from django.shortcuts import render
 from django.http import HttpResponseRedirect

 def get_name(request):
     # if this is a POST request we need to process the form data
     if request.method == 'POST':
         # create a form instance and populate it with data from the
 request:
         form = NameForm(request.POST)
         # check whether it's valid:
         if form.is_valid():
             # process the data in form.cleaned_data as required
             # ...
             # redirect to a new URL:
             return HttpResponseRedirect('/thanks/')

     # if a GET (or any other method) we'll create a blank form
     else:
         form = NameForm()

     return render(request, 'name.html', {'form': form})

 If you call NameForm() #2nd to last line of code
 Won't that cause an import error?

 https://docs.djangoproject.com/en/1.7/topics/forms/

--
Ticket URL: <https://code.djangoproject.com/ticket/23904>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.7bd976132e98a31bdbfdc05b2d127be0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to