“Zugriffsfeldwerte von Form Django” Code-Antworten

Zugriffsfeldwerte von 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,
    })

Nice Nightingale

Zugriffsfeldwerte von Form Django

>>> data = {'subject': 'hello',
...         'message': 'Hi there',
...         'sender': '[email protected]',
...         'cc_myself': True}
>>> f = ContactForm(data)
>>> f.is_valid()
True
>>> f.cleaned_data
{'cc_myself': True, 'message': 'Hi there', 'sender': '[email protected]', 'subject': 'hello'}
Victorious Vole

Ähnliche Antworten wie “Zugriffsfeldwerte von Form Django”

Fragen ähnlich wie “Zugriffsfeldwerte von Form Django”

Weitere verwandte Antworten zu “Zugriffsfeldwerte von Form Django” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen