我使用标准的 django 评论框架。
模板:
<h2>Add comment</h2> {% get_comment_form for post as form %}
<form action="{% comment_form_target %}" method="post" > {% csrf_token %}
{{form.content_type}}{{form.object_pk}}{{form.timestamp}}{{form.security_hash}}
Comment:<br />
{{form.comment}}
<input type="hidden" name="next" value="{{ request.get_full_path }}#comment" />
<button class="btn btn-large btn-primary" type="submit">Post</button>
</form>
网址:
(r'^comments/', include('django.contrib.comments.urls')),
然后我发送空表单,我重定向到 /comments/post/ 页面。我怎样才能重新加载当前页面并添加错误消息?谢谢!