def providers_new(request): if request.method == "POST": form = ProveedorForm(request.POST) if form.is_valid(): obj = form.save() return redirect("/providers/new") form = ProveedorForm() return render( request, 'proveedor_nuevo.html', { 'form':form, 'current_time':datetime.datetime.now(), } )
def addProveedores(request): if request.method == 'POST': # formulario enviado proveedoresform = ProveedorForm(request.POST) if proveedoresform.is_valid(): # formulario validado correctamente proveedoresform.save() return HttpResponseRedirect('/categorias/') else: # formulario inicial formset = ProveedorForm() return render_to_response('puntoventa/addProducto.html', { 'formset': ProveedorForm }, context_instance=RequestContext(request))
def providers_edit(request, id="1"): provider = Proveedor.objects.get(pk=id) if request.method == "POST": form = ProveedorForm(request.POST, instance=provider) if form.is_valid(): obj = form.save() return redirect("/providers/"+obj.pk) form = ProveedorForm(instance=provider) return render( request, 'proveedor_detalle.html', { 'provider':provider, 'form':form, 'current_time':datetime.datetime.now(), } )