Beispiel #1
0
def adiciona_fonterac(request):
    if request.method == "POST":
        form = FormFonteRAC(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return render_to_response(
                "fonterac/add_fonterac.html", {"form": form}, context_instance=RequestContext(request)
            )
    else:
        form = FormFonteRAC()
    return render_to_response("fonterac/add_fonterac.html", {"form": form}, context_instance=RequestContext(request))
Beispiel #2
0
def edita_fonterac(request, nr_item):
    objeto = FonteRAC.objects.get(pk=nr_item)
    if request.method == "POST":
        form = FormFonteRAC(request.POST, instance=objeto)
        if form.is_valid():
            form.save()
            return render_to_response(
                "fonterac/edita_fonterac.html", {"form": form}, context_instance=RequestContext(request)
            )
    else:
        form = FormFonteRAC(instance=objeto)
    return render_to_response("fonterac/edita_fonterac.html", {"form": form}, context_instance=RequestContext(request))