show_more.html(这是Post的模板,请参阅注释和添加注释(
<hr>
{% for comment in comments %}
<div class="comment">
<p class="info">
{{ comment.created_at|naturaltime }}
Commented by :- <a href="{% url 'mains:show_profile' comment.commented_by.id %}"></a> # I think the problem is in this line. BUT i've tried everything.
{{ topic.post_owner }}
</p>
{{ comment.comment_body|linebreaks }}
</div>
{% empty %}
<p>There are no comments yet.</p>
{% endfor %}
我什么都试过了,但都不管用,请帮帮我。我将非常感谢你的帮助。
您需要将comment.commeted_by.id传递到URL的kwarg'user_id'
<a href="{% url 'mains:show_profile' user_id=comment.commented_by.id %}"> {{ comment.commented_by }} </a>
请尝试
comment.commented_by
而不是
comment.commented_by.id.