def actualizar_receta(request, id_receta): #update dato = get_object_or_404(Receta, pk=id_receta) formulario = RecetaForm(request.POST or None, instance=receta) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('new_R') return render(request, 'recetaform.html', {'formulario': formulario})
def actualizar_receta(request, id_receta): #update dato = get_object_or_404(Receta, pk=id_receta) formulario = RecetaForm(request.POST or None, instance=receta) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('new_R') return render(request, 'recetaform.html', {'formulario':formulario})
def nueva_receta(request): if request.method == 'POST': formulario = RecetaForm(request.POST, request.FILES) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/recetas') else: formulario = RecetaForm() return render_to_response('recetaform.html',{'formulario':formulario},context_instance=RequestContext(request))
def nueva_receta(request): if request.method == "POST": form = RecetaForm(request.POST, request.FILES) if form.is_valid(): form.save() return HttpResponseRedirect("/") else: form = RecetaForm() return render_to_response("nueva_receta.html", {"form": form}, context_instance=RequestContext(request))
def nueva_receta(request): # POST: Es una coleccion de dato que envía if request.method == 'POST': formulario = RecetaForm(request.POST, request.FILES) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/') else: formulario = RecetaForm() return render_to_response('principal/recetaform.html', {'formulario': formulario}, context_instance=RequestContext(request))
def nueva_receta(request): if not request.user.is_authenticated(): return HttpResponseRedirect('/ingresar') if request.method == 'POST': formulario = RecetaForm(request.POST, request.FILES) f_receta = formulario.save(commit=False) f_receta.usuario = request.user if formulario.is_valid(): f_receta.save() return HttpResponseRedirect('/recetario') else: formulario = RecetaForm return render_to_response('recetaform.html', {'formulario': formulario}, context_instance=RequestContext(request))
def nueva_receta(request): if request.method=='POST': formulario = RecetaForm(request.POST, request.FILES) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/recetas') else: formulario = RecetaForm() return render_to_response('recetaform.html',{'formulario':formulario},context_instance=RequestContext(request))
def nueva_receta(request): # POST: Es una coleccion de dato que envía if request.method == 'POST': formulario = RecetaForm(request.POST, request.FILES) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/') else: formulario = RecetaForm() return render_to_response('principal/recetaform.html', {'formulario': formulario}, context_instance=RequestContext(request))