Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Access field values of form django


def contact(request):
    if request.method == 'POST': # If the form has been submitted...
        form = ContactForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            # ...

            print form.cleaned_data['my_form_field_name']

            return HttpResponseRedirect('/thanks/') # Redirect after POST
    else:
        form = ContactForm() # An unbound form

    return render_to_response('contact.html', {
        'form': form,
    })

Comment

Access field values of form django

>>> data = {'subject': 'hello',
...         'message': 'Hi there',
...         'sender': 'foo@example.com',
...         'cc_myself': True}
>>> f = ContactForm(data)
>>> f.is_valid()
True
>>> f.cleaned_data
{'cc_myself': True, 'message': 'Hi there', 'sender': 'foo@example.com', 'subject': 'hello'}
Comment

PREVIOUS NEXT
Code Example
Python :: pandas index append value 
Python :: python string replace 
Python :: python set workspace dir 
Python :: Django - Knox auth setup 
Python :: pip install pandas invalid syntax 
Python :: to get the number of unique values for each column 
Python :: iloc pandas 
Python :: Python NumPy stack Function Example with 2d array 
Python :: pygame template 
Python :: circle python programe 
Python :: python screeninfo 
Python :: python keyerror 
Python :: python for loop practice problems 
Python :: python iterating over a list 
Python :: check dictionary values pandas dataframe colu 
Python :: python collections to dictionary 
Python :: python ide 
Python :: python import as 
Python :: dimension of an indez pandas 
Python :: font tkinter combobox 
Python :: repl.it install packages python 
Python :: python single vs double quotes 
Python :: pandas read parquet from s3 
Python :: how to make an array python 
Python :: update python 2 to 3 
Python :: python typing module list 
Python :: how to while true python 
Python :: python how to use rnage 
Python :: how to register a model in django 
Python :: base64 python flask html 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =