def comment_new(request, object_id=None, form_instance=None): form = CommentForm() if object_id: comment = get_object_or_404(Comment, pk=object_id) form = CommentForm(instance=comment) else: comment = None return render(request, 'comment_form.html', { 'form': form, 'instance': comment })
def comment_detail(request, object_id): queryset = Comment.objects.all() form = CommentForm() comment = get_object_or_404(Comment, pk=object_id) if request.method == "POST": next = request.POST["next"] form = CommentForm(request.POST, instance=comment) if form.is_valid(): comment = form.save(commit=False) comment.tags = u"comentario," comment.save() messages.success(request, "Actualizaste el #%s" % (object_id)) return redirect(next) else: return comment_new(request, object_id=object_id, form_instance=form) return render(request, "detail.html", {"comment_form": form, "object": comment, "object_list": queryset})
def comment_list(request): queryset = Comment.objects.all().order_by("changed") if not request.user.is_staff: queryset = queryset.exclude(is_draft=True) form = CommentForm() if request.method == "POST" and request.POST["honeypot"] == "": next = request.POST["next"] form = CommentForm(request.POST) if form.is_valid(): comment = form.save(commit=False) comment.tags = u"comentario," comment.save() messages.success(request, u"Mensaje publicado con exito.") return redirect(next) else: return comment_new(request, form_instance=form) return render(request, "master.html", {"comment_form": form, "object_list": queryset})
def comment_list(request): queryset = Comment.objects.all().order_by('changed') if not request.user.is_staff: queryset = queryset.exclude(is_draft=True) form = CommentForm() if request.method == 'POST' and request.POST['honeypot'] == '': next = request.POST['next'] form = CommentForm(request.POST) if form.is_valid(): comment = form.save(commit=False) comment.tags = u'comentario,' comment.save() messages.success(request, u'Mensaje publicado con exito.') return redirect(next) else: return comment_new(request, form_instance=form) return render(request, 'master.html', { 'comment_form': form, 'object_list': queryset, })
def comment_detail(request, object_id): queryset = Comment.objects.all() form = CommentForm() comment = get_object_or_404(Comment, pk=object_id) if request.method == 'POST': next = request.POST['next'] form = CommentForm(request.POST, instance=comment) if form.is_valid(): comment = form.save(commit=False) comment.tags = u'comentario,' comment.save() messages.success(request, 'Actualizaste el #%s' % (object_id)) return redirect(next) else: return comment_new(request, object_id=object_id, form_instance=form) return render(request, 'detail.html', { 'comment_form': form, 'object': comment, 'object_list': queryset, })