예제 #1
0
def editar(request, id_alumno):
    alumno = registro.objects.get(pk=id_alumno)
    if request.method == "POST":
        formulario = FormularioAdd(request.POST, instance=alumno)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect("/")
    else:
        formulario = FormularioAdd(instance=alumno)
    return render_to_response("editar.html", {"formulario": formulario}, context_instance=RequestContext(request))
예제 #2
0
def agregar(request):
    if request.method == "POST":
        formulario = FormularioAdd(request.POST)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect("/")
    else:
        formulario = FormularioAdd()

    return render_to_response("agregar.html", {"formulario": formulario}, context_instance=RequestContext(request))