Re: Doesn't display any comments
Your template code should be in the same line. like:
the template code:
<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|
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(
id=bookmark_id)
variables = RequestContext(request, {
'shared_bookmark' : shared_bookmark
})
return render_to_response('bookmark_
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 %}
On Sunday, November 27, 2011 1:40:05 AM UTC-5, Tsung-Hsien wrote:
I use comment of Django applicaition, and the comment page looks--
anything good, but when I post the comment, there is no comment
displayed on the page without any problem showing.the template code:
<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 %}I tried replace shared_bookmark.id with
object_pk,causing the page can't display the comment form.How to fix this?
Thanks!
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