Exemplo n.º 1
0
def nueva_receta(request):
    if request.method == 'POST':
        formulario = RecetasForm(request.POST, request.FILES)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect('/Recetas')
    else:
        formulario = RecetasForm()
    return render_to_response('nueva_receta.html', {'formulario': formulario}, context_instance=RequestContext(request))
Exemplo n.º 2
0
def Modificar_receta(request, id_cat):
    if request.user.is_authenticated():
        receta = get_object_or_404(Recetas, id=id_cat)
        if request.method == 'POST':
            formulario = RecetasForm(request.POST, request.FILES, instance=receta)
            if formulario.is_valid():
                formulario.save()
                return HttpResponseRedirect('/Recetas/')
        else:
            formulario = RecetasForm(instance=receta)

        return render_to_response('producto/mod_receta.html', {'formulario': formulario},context_instance=RequestContext(request))
    else:
        return HttpResponseRedirect('/modreceta/')