Example #1
0
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))            
Example #2
0
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))