我有删除评论的问题。在我的 movies_details.html 我有
{% render_comment_list for object %}
我已经在我的项目模板文件夹中重写了 comments/list.html,它看起来像
<div class="comment_start">
<div class="comment">
<table>
{% autopaginate comment_list 5 %}
{% for comment in comment_list %}
<tr>
<td>
{{ comment.comment }}
</td>
<td>
(from <strong><i><u>{{ comment.user }}</u></i></strong> <br> {{ comment.submit_date|timesince }} ago)
<br>
{% if user.is_authenticated and comment.user == user %}
{% url mysite.views.delete_own_comment comment_id=comment.id as delete_url %}
<a href="{{ delete_url }}">Delete</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% paginate %}
</div>
</div>
在视图中,路径是 mysite/views,我有 delete_own_comment 视图
def delete_own_comment(request, comment_id):
comment = get_object_or_404(Comment, id=comment_id)
if comment.user.id != request.user.id:
raise Http404
perform_delete(request, comment)
当我点击删除按钮时,它只是刷新页面而不删除评论,我不知道问题出在哪里