Skip to content

Instantly share code, notes, and snippets.

@ateoto
Created February 22, 2010 16:00
Show Gist options
  • Save ateoto/311192 to your computer and use it in GitHub Desktop.
Save ateoto/311192 to your computer and use it in GitHub Desktop.
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