[Django] #23904: Forms Overview

10 views
Skip to first unread message

Django

unread,
Nov 24, 2014, 9:15:16 AM11/24/14
to django-...@googlegroups.com
#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.

Django

unread,
Nov 24, 2014, 9:15:49 AM11/24/14
to django-...@googlegroups.com
#23904: Forms Overview
-------------------------------------+-------------------------------------
Reporter: Brett55 | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.7
Component: Documentation | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Brett55):

* component: Uncategorized => Documentation
* needs_better_patch: => 0
* type: Uncategorized => Cleanup/optimization
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/23904#comment:1>

Django

unread,
Nov 24, 2014, 9:21:19 AM11/24/14
to django-...@googlegroups.com
#23904: Forms Overview
-------------------------------------+-------------------------------------
Reporter: Brett55 | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.7
Component: Documentation | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bmispelon):

Hi,

The assumption is that we're reusing the `NameForm` defined in the
previous paragraph [1].

The whole section is meant to be read sequentially so I don't know if we
need to make that more explicit.

What do you think?

Thanks.

[1] https://docs.djangoproject.com/en/1.7/topics/forms/#the-form-class

--
Ticket URL: <https://code.djangoproject.com/ticket/23904#comment:2>

Django

unread,
Nov 25, 2014, 9:53:03 AM11/25/14
to django-...@googlegroups.com
#23904: Forms Overview
-------------------------------------+-------------------------------------
Reporter: Brett55 | Owner: nobody
Type: | Status: closed

Cleanup/optimization | Version: 1.7
Component: Documentation | Resolution:
Severity: Normal | worksforme
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => worksforme


--
Ticket URL: <https://code.djangoproject.com/ticket/23904#comment:3>

Reply all
Reply to author
Forward
0 new messages