Advancing the Blog – 18 – Comment Thread



Advancing the Blog – 18 – Comment Thread

** Advancing the Blog ** is an extended look at building a modern blog with the Django Framework while leveraging other technologies such as jQuery, Markdown, Bootstrap, APIs, and more.

We will be starting where Try Django 1.9 left off to create a powerful blog ready for the modern era. It is highly recommend to start with Try Django 1.9 before starting this series.

Watch Try Django 1.9 here:…

12 Comments

  1. hey Justin help!!….
    AttributeError at /comments/2/
    'NoneType' object has no attribute 'model'

    it's pointing here but i don't see any error i mean why can't i pass the model?
    obj = get_object_or_404(Comment, id=abc)

    Can anyone help? i am stuck in here!!

  2. Getting this error : Reverse for 'comment_thread' with arguments '()' and keyword arguments '{u'id': 6}' not found. 0 pattern(s) tried: []

    Code:

    post_detail.html

    {% for comment in comments %}
    <blockquote> <!-For Comments->

    <p>{{ comment.content }}</p>
    <footer>via {{ comment.user }} | {{ comment.timestamp|timesince }} ago | {% if comment.children.count > 0 %}{{ comment.children.count }} Comment{% if comment.children.count > 1 %}s{% endif %} | {% endif %}
    <a class="comment-reply-btn" href="#">Reply</a> | <a class="" href="{{ comment.get_absolute_url }}">Thread</a></footer>
    <div class="comment-reply">
    {% for child_comment in comment.children %}
    <blockquote> <!-For Replies –>
    <p>{{ child_comment.content }}</p>
    <footer>via {{ child_comment.user }} | {{ child_comment.timestamp|timesince }} ago</footer>
    </blockquote>
    {% endfor %}

    Reply as soon : #CodingEntrepreneurs

  3. i try to type in the same content inside the comment and post it. but it won't let me. do you have some kind of spam blocking function in the comment app? it works perfectly fine if the content is different. waiting for anyone else's reply.

  4. Hi Justin. I have this problem Page not Found(404) in the part of the tutorial when I add the obj = get_object_or_404(Comment, id=abc):

    Here is my complete code for comments views.py

    from django.shortcuts import render, get_object_or_404

    from .models import Comment

    def comment_thread(request, abc)
    obj = get_object_or_404(Comment, id=abc)
    context = {
    "object": obj,
    }
    return render(request, "comment_thread.html", context

    Here is my comments urls.py

    from django.conf.urls import url
    from django.contrib import admin

    from .views import(
    comment_thread,
    )

    urlpatterns = [
    url(r'^(?P<abc>d+)/$', comment_thread, name='thread'),

    ]

    In my blog urls I also add my url pattern for comments

  5. to redirect to the comment_thread.html page and not to the post_detail.html, use return HttpResponseRedirect(obj.get_absolute_url()) instead of return HttpResponseRedirect(new_comment.content_object.get_absolute_url())

    Love your videos very helpful!!!!!!!

Leave a Reply

Your email address will not be published.


*