def adiciona_equip(request): if request.method == "POST": form = FormEquipamento(request.POST, request.FILES) if form.is_valid(): form.save() return render_to_response( "gas_equip/add_equip.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormEquipamento() return render_to_response("gas_equip/add_equip.html", {"form": form}, context_instance=RequestContext(request))
def edita_equip(request, nr_item): objeto = Equipamento.objects.get(pk=nr_item) if request.method == "POST": form = FormEquipamento(request.POST, instance=objeto) if form.is_valid(): form.save() return render_to_response( "gas_equip/edita_equip.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormEquipamento(instance=objeto) return render_to_response("gas_equip/edita_equip.html", {"form": form}, context_instance=RequestContext(request))