0

I am trying to implement a comment section on my app that keeps track of bookmarks. This is the output that I got when I ran my local host server. It is not what I expected and I can't find out what's wrong. I expected there to be a comment form, a number for the comment count, and a comment list. But the webpage just rendered my code. This is the output that i got This is the code

{% extends "base.html" %}
{% load comments %}
{% block title %}Bookmark:
{{ shared_bookmark.bookmark.title|escape }}{% endblock %}
{% block head %}


  <h2> Comments</h2>
  {% get_comment_count for bookmarks.sharedbookmark   
       shared_bookmark.id as comment_count %} 
  {% get_comment_list for bookmarks.sharedbookmark   
       shared_bookmark.id as comment_list %} 


   {% for comment in comment_list %}  
   <div class="comment">
             <p><b>{{ comment.user.username }}</b> said:</p>     
             {{ comment.comment|escape|urlizetrunc:40|linebreaks }}    
             </div> 
             {% endfor %}  
             <p>Number of comments: {{ comment_count }}</p> 
             {% comment_form for bookmarks.sharedbookmark    
             shared_bookmark.id %} 

{% endblock %}

Thanks for your help!

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Victory Omole
  • 693
  • 1
  • 6
  • 15
  • You need to show how you are rendering that template. – Daniel Roseman May 24 '16 at 14:21
  • Can you include `base.html` here? – iLikeBreakfast May 24 '16 at 14:24
  • 1
    The Django comments framework is an optional module. Have you enabled it in `settings.py`? – John Gordon May 24 '16 at 14:26
  • 1
    Also, why are you using `bookmarks.sharedbookmark shared_bookmark.id`? Wouldn't it be more direct to just use `shared_bookmark`? – John Gordon May 24 '16 at 14:27
  • @JohnGordon yes here is my INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', #'django.contrib.comments', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_comments', 'hello', 'comments', 'bookmarks', ) – Victory Omole May 24 '16 at 14:33
  • @JohnGordon I'm actually new to Django, so i'm just copying code that I found in a book here is the book: http://slav0nic.org.ua/static/books/python/Packt.Publishing.Learning.Website.Development.with.Django.Mar.2008.pdf – Victory Omole May 24 '16 at 14:36
  • 1
    @VicktoryCalculusManOmole it looks like the comments module is commented out: `#'django.contrib.comments'` – John Gordon May 24 '16 at 14:36
  • @JohnGordon I had to comment out that one because it's deprecated and I had to use the new "django_comments" – Victory Omole May 24 '16 at 14:37
  • 1
    I'm not sure that Django tags can be split on two lines like you have. Try making one single long line for `{% get_comment_count ...` – John Gordon May 24 '16 at 14:38
  • My base.html | {% block title %}{% endblock %} {% if user.is_authenticated %} welcome {{ user.username }} (logout) {% else %} {% endif %}

    {% block head %}{% endblock %}

    {% block content %}{% endblock %}
    – Victory Omole May 24 '16 at 14:38
  • 1
    @VicktoryCalculusManOmole it's better to add information by editing your original question, instead of adding it in comments. – John Gordon May 24 '16 at 14:39
  • @JohnGordon Ok, thanks for the tip! I added everything to one line and I got "Invalid block tag on line 20: 'comment_form', expected 'endblock'. Did you forget to register or load this tag?". I am trying to look around online for any clues. – Victory Omole May 24 '16 at 14:54
  • 1
    Did you mean to use `render_comment_form`? – John Gordon May 24 '16 at 15:04
  • @JohnGordon Thank you so much everything works now! Thank you for being patient with me and helping me till the end. A lot of people in this community wouldn't have done the same. Again, thank you so much; and have a good day :). – Victory Omole May 24 '16 at 15:14

0 Answers0