Пример #1
0
def add_persona(request):
	if request.method=='POST':
		formulario = PersonaForm(request.POST)
		if formulario.is_valid():
			formulario.save()
			return HttpResponseRedirect('/usuarios/page/1')
	else:
		formulario = PersonaForm()
	return render_to_response('personaform.html',{'formulario':formulario},context_instance=RequestContext(request))
Пример #2
0
def edit_persona(request,id_persona):
	persona = Persona.objects.get(id=id_persona)
	
	if request.method == 'POST':
		formulario = PersonaForm(request.POST,instance=persona)
		if formulario.is_valid():
			formulario.save()
			return HttpResponseRedirect('/usuarios/%s/'%persona.id)
	else:
		formulario = PersonaForm(instance=persona)
	

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