我在我的模板呈現中收到NoReverseMatch錯誤。Django NoReverseMatch錯誤,有效的URL配置和視圖
下面是相關的模板:
<ul id='comments'>
{% for comment in comments %}
<li class='comment'>
<img class='gravatar' src='{{ comment.User|gravatar:50}}' alt='{{ comment.User.get_full_name }}' \>
<a href='{% url 'dashboard.views.users.profile' comment.User.id %}' class='user'>
{{comment.User.get_full_name}}
</a>
<p class='comment-timestamp'>{{comment.created}}</p>
<p class='comment-content'>{{comment.comment|striptags}}<br>
{% if user == comment.user or user = report.user %}
<a href="{% url 'mokr.delete_comment' comment.id %}">Delete</a></p>
{% endif %}
</li>
{% endfor %}
該錯誤的URL 'mokr.delete_comment' 線
給這裏的觀點:
def delete_comment(request, comment_id):
comment = get_object_or_404(ReportComment, id = comment_id)
report = comment.MgmtReport
comment.delete()
project = report.project
return HttpResponseRedirect(reverse('show_post', args=(project.url_path, report.id)))
和網址的部分。 py
(r'^mokr/comment/(\d+)/delete/$', mokr.delete_comment),
url(r'^mokr/show/([^\.]*)/(\d+)/$', mokr.show, name='show_post'),
你永遠不叫你的網址,你需要'name ='在你的URL模式刪除,comment''。 –