def adiciona_fonte(request): if request.method == "POST": form = FormFonteEmissaoECV(request.POST, request.FILES) if form.is_valid(): form.save() return render_to_response( "fonteecv/add_fonte.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormFonteEmissaoECV() return render_to_response("fonteecv/add_fonte.html", {"form": form}, context_instance=RequestContext(request))
def edita_fonte(request, nr_item): objeto = FonteEmissaoECV.objects.get(pk=nr_item) if request.method == "POST": form = FormFonteEmissaoECV(request.POST, instance=objeto) if form.is_valid(): form.save() return render_to_response( "fonteecv/edita_fonte.html", {"form": form}, context_instance=RequestContext(request) ) else: form = FormFonteEmissaoECV(instance=objeto) return render_to_response("fonteecv/edita_fonte.html", {"form": form}, context_instance=RequestContext(request))