def update(request, customer_id): if request.method == 'POST': customer = Customer.objects.get(id=customer_id) form = CustomerForm(request.POST, instance=customer) if form.is_valid(): form.save() return redirect('/clientes') else: return render_to_response('customer_edit.html', locals(), context_instance=RequestContext(request))
def create(request): if request.method == 'POST': customer = Customer() form = CustomerForm(request.POST, instance=customer) if form.is_valid(): form.save() return redirect('/clientes') else: return render_to_response('customer_new.html', locals(), context_instance=RequestContext(request))