Exemple #1
0
def editHistorial(request):
    errors = None

    dni = request.POST.get("dni")
    instance = Historial.objects.get(dni=dni)
    form = HistorialForm(request.POST or None, instance=instance)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect("/detalleHistorial/" + dni)
    else:
        errors = form.errors
        print(errors)
        historial = HistorialForm()
    return render_to_response(
        "editarHistorial.html", {"historial": instance, "errors": errors}, context_instance=RequestContext(request)
    )
Exemple #2
0
def nuevoHistorial(request):
    errors = None
    if request.method == "POST":
        historial = HistorialForm(request.POST, request.FILES)
        dni = request.POST.get("dni")

        if historial.is_valid():
            historial.save()
            return HttpResponseRedirect("/detalleHistorial/" + dni)
        else:
            errors = historial.errors
            print(errors)

    else:
        historial = HistorialForm()
    return render_to_response(
        "nuevoHistorial.html", {"historial": historial, "errors": errors}, context_instance=RequestContext(request)
    )