Created
February 22, 2010 16:00
-
-
Save ateoto/311192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def submit_form(request): | |
response = dict() | |
if request.method == 'POST': | |
af = AwesomeForm(request.POST) | |
if af.is_valid(): | |
af_field_variable = af.cleaned_data['awesome_field']) | |
messages.success(request, 'Thanks for the form data!') | |
return render_to_response("awesome_form_thanks.html", | |
response, | |
context_instance=RequestContext(request)) | |
else: | |
messages.error(request, 'Please fix the fields below!') | |
response['awesome_form'] = af | |
return render_to_response("awesome_form.html", | |
response, | |
context_instance=RequestContext(request)) | |
else: | |
response['awesome_form'] = AwesomeForm() | |
return render_to_response("awesome_form.html", | |
response, | |
context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment