def nuevo_cliente(request): if request.method=='POST': form = FormClientes(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/clientes/') else: form = FormClientes() return render_to_response('add_cliente.html', {'form': form}, context_instance=RequestContext(request))
def cliente(request, id): cliente = Clientes.objects.get(id=id) if request.method=='POST': form = FormClientes(request.POST, instance=cliente) if form.is_valid(): cliente = form.save(commit=False) cliente.id = request.id cliente.save() #form.save() return HttpResponseRedirect('/clientes/') else: form = FormClientes() return render_to_response('cliente.html', {'cliente':cliente}, context_instance=RequestContext(request))