def adiciona_gas(request): if request.method == "POST": form = FormGas(request.POST, request.FILES) if form.is_valid(): form.save() return render_to_response( "gas_equip/add_gas.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormGas() return render_to_response("gas_equip/add_gas.html", {"form": form}, context_instance=RequestContext(request))
def edita_gas(request, nr_item): objeto = Gas.objects.get(pk=nr_item) if request.method == "POST": form = FormGas(request.POST, instance=objeto) if form.is_valid(): form.save() return render_to_response( "gas_equip/edita_gas.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormGas(instance=objeto) return render_to_response("gas_equip/edita_gas.html", {"form": form}, context_instance=RequestContext(request))