def nuevaentrada(request): if request.method=='POST': formulario=EntradaForm(request.POST) if formulario.is_valid(): entrada=formulario.save(commit=False) entrada.author=request.user entrada.publicado=True entrada.save() return HttpResponseRedirect('/') else: formulario=EntradaForm() return render_to_response('nueva_entrada.html', {'formulario':formulario}, context_instance=RequestContext(request))
def editar_entrada(request, id_entrada): usuario = request.user entrada = Entry.objects.get(pk=id_entrada) if usuario == entrada.author: if request.method == 'POST': formulario = EntradaForm(request.POST, instance=entrada) if formulario.is_valid(): formulario.save() return HttpResponseRedirect('/misentradas') else: formulario = EntradaForm(instance=entrada) return render_to_response('nueva_entrada.html', {'formulario':formulario}, context_instance=RequestContext(request)) else: return render_to_response('/ingresar', context_instance=RequestContext(request))