Saturday, May 18, 2013

Re: Doesn't display any comments

Try this template code:The template tags should be lined up in one single line.

        <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>Posted by: {{ comment.user_name }} on
{{ comment.submit_date }}</p>
                        {{ comment.comment|escape|urlizetrunc:40|
linebreaks }}
                </div>
        {% endfor%}
        <p>Number of comments: {{ comment_count }}</p>
        {% render_comment_form for bookmarks.sharedbookmark shared_bookmark.id %}

view.py:

def bookmark_page(request, bookmark_id):
        shared_bookmark = get_object_or_404(SharedBookmark,
id=bookmark_id)
        variables = RequestContext(request, {
                'shared_bookmark' : shared_bookmark
        })
        return render_to_response('bookmark_page.html', variables)

form.html:
{% if user.is_authenticated %}
    <form action="{{ comment_form_target }}" method="post">
        {% csrf_token %}
        <p><label>Post a comment:</label><br />
        <textarea name="comment" rows="10" cols="60"></textarea></p>
        <input type="hidden" name="options" value="{{ options }}" />
        <input type="hidden" name="target" value="{{ target }}" />
        <input type="hidden" name="gonzo" value="{{ hash }}" />
        <input type="submit" name="post" value="submit comment" />
    </form>
{% else %}
    <p>Please <a href="/login/">log in</a> to post comments.</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate