I have many methods. All you can pick.
I suppose the form is like as below:
class SignupForm(forms.Form):
email = forms.CharField(label='email')
password = forms.CharField(label='password',
widget=forms.PasswordInput)
1-1. Get from request
def signup(req):
if req.method == 'POST':
email = req.POST.get('email', '')
password = req.POST.get('password', '')
2-1. Get the raw value
assigned to the field and return the value of the data
attribute of field
def signup(req):
if req.method == 'POST':
...
sf = SignupForm(req.POST)
email = sf["email"].data
password = sf["password"].data
...
2-2. Get the raw value assigned to the field and return the value of the value
attribute of field
def signup(req):
if req.method == 'POST':
...
sf = SignupForm(req.POST)
email = sf["email"].value()
password = sf["password"].value()
...
2-3. Get the dictionary
assigned to the fields
def signup(req):
if req.method == 'POST':
...
sf = SignupForm(req.POST)
# print sf.data
# <QueryDict: {u'csrfmiddlewaretoken': [u'U0M9skekfcZiyk0DhlLVV1HssoLD6SGv'], u'password': [u''], u'email': [u'hello']}>
email = sf.data.get("email", '')
password = sf.data.get("password", '')
...