def adiciona_setor(request): if request.method=='POST': form=SetorForm(request.POST,request.FILES) if form.is_valid(): form.save() return render_to_response('setor/adiciona_setor.html',{'form':form}, context_instance=RequestContext(request)) else: form=SetorForm() return render_to_response('setor/adiciona_setor.html',{'form':form}, context_instance=RequestContext(request) )
def edita_setor(request,nr_item): objeto=SetorAtividade.objects.get(pk=nr_item) if request.method=='POST': form=SetorForm(request.POST,instance=objeto) if form.is_valid(): form.save() return render_to_response('setor/edita_setor.html',{'form':form},context_instance=RequestContext(request)) else: form=SetorForm(instance=objeto) return render_to_response('setor/edita_setor.html',{'form':form},context_instance=RequestContext(request))