Exemple #1
0
def editar(request,nr_organ):
    org = get_object_or_404(Organ,pk=nr_organ)
    form = FormOrgan(instance=org)
    if request.method=="POST":
        form = FormOrgan(request.POST,request.FILES,instance=org)
        if form.is_valid():
            tip = form.save(commit=False)
            tip.save()
            return HttpResponseRedirect('/orgao')
    return render_to_response("organs/editar_organ.html",{'form':form},
        context_instance=RequestContext(request))
Exemple #2
0
def create(request):
    if request.method =="POST":
        form = FormOrgan(request.POST, request.FILES)
        if form.is_valid():
            item = form.save(commit=False)
            item.save()
            form.save_m2m()
            return HttpResponseRedirect('/orgao/')
    else:
        form = FormOrgan()
    return render_to_response("organs/novoOrgao.html",{'form':form},context_instance=RequestContext(request))