def add_cartera(request): if request.method=='POST': formulario = CarteraForm(request.POST) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/carteras/') else: formulario = CarteraForm() return render_to_response('carteraform.html',{'formulario':formulario},context_instance=RequestContext(request))
def edit_cartera(request,id_cartera): cartera = Cartera.objects.get(id=id_cartera) if request.method == 'POST': formulario = CarteraForm(request.POST,instance=cartera) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/cartera/%s/'%cartera.id) else: formulario = CarteraForm(instance=cartera) return render_to_response('edit_carteraform.html',{'formulario':formulario},context_instance=RequestContext(request))