django删除评论按钮?

时间:2013-06-20 09:55:47

标签: django button comments

我删除评论时遇到问题。 在我的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>

并且在视图中,path是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)

当我点击删除按钮时,它只刷新页面而不删除评论,我不知道问题出在哪里

0 个答案:

没有答案