Пример #1
0
def show_restaurante(request):
    if request.method == "POST":
        form = RestauranteForm(request.POST)

        if form.is_valid():
            form.save()
            form = RestauranteForm()

    else:
        form = RestauranteForm()

    restaurantes = get_restaurantes()

    return render_to_response(
        "restaurantes.html", {"restaurantes": restaurantes, "form": form}, context_instance=RequestContext(request)
    )
Пример #2
0
def cargar_restaurante(request, id):

    try:
        restaurante = Restaurante.objects.get(id=id)

    except:
        raise Http404

    else:
        if request.method == "POST":
            form = RestauranteForm(request.POST, instance=restaurante)

            if form.is_valid():
                form.save()
                form = RestauranteForm(instance=restaurante)

        else:
            form = RestauranteForm(instance=restaurante)

        return render_to_response(
            "restaurante_id.html", {"restaurante": restaurante, "form": form}, context_instance=RequestContext(request)
        )