示例#1
0
def persona_add(request):
	if request.method == 'POST':
		formulario = FichaForm(request.POST)
		if formulario.is_valid():
			formulario.save()
			return HttpResponseRedirect('/ficha/')
	else:
		formulario = FichaForm()
	return render_to_response('persona_view.html', {'formulario':formulario}, context_instance=RequestContext(request))
示例#2
0
def index(request):
	errores = ''
	if request.is_ajax() and request.method == 'POST':
		form = FichaForm(request.POST)	
		if form.is_valid():
			form.save()
			success = True
		else:
			success = False
			errores = form.errors
			return render_to_json(simplejson.dumps({'errores':errores, 'success': success}))

	else:
		formulario = FichaForm()
		return render_to_response('ejemplo_ajax.html', {'formulario':formulario}, context_instance=RequestContext(request))