def comenta_pelicula(request, id_pelicula): if request.method == 'POST': formulario = Comenta(request.POST) if formulario.is_valid(): autor = request.user com = formulario.cleaned_data['comentario'] comen = Comentario.objects.create(autor=autor, comentario=com) pelicula = Pelicula.objects.get(id=id_pelicula) pelicula.comentarios.add(comen) return redirect('/pelicula/'+str(pelicula.id)) return redirect('/error/')
def comenta_director(request, id_director): if request.method == 'POST': formulario = Comenta(request.POST) if formulario.is_valid(): autor = request.user com = formulario.cleaned_data['comentario'] comen = Comentario.objects.create(autor=autor, comentario=com) director = Director.objects.get(id=id_director) director.comentarios.add(comen) return redirect('/director/'+str(director.id)) else: formulario = Comenta() ctx = {'formulario':formulario} return render(request, 'privada.html', ctx)