サイトの 2 か所で Django コメント フレームワークを使用しています。送信するたびに、ユーザーが元のページにリダイレクトされるようにしたいと思います。
ユーザーがリダイレクトされるように「次の」変数をどのように定義しますか?
リダイレクトに関する情報 : http://docs.djangoproject.com/en/dev/ref/contrib/comments/#redirecting-after-the-comment-post
また、私が使用しているフォームは次のとおりです。comment.types は機能しませんが、それが私がすべきことだと思います。各コメント タイプ (画像と食事) に対して 2 つの異なる次の入力を定義します。
{% load comments i18n %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
{% if comment.type == '19' %}
<input type="hidden" name="next" value="{% url meal comment.object_pk %}" />
{% endif %}
{% if comment.type == '23' %}
<input type="hidden" name="next" value="{% url picture comment.object_pk %}" />
{% endif %}
<!-- <input type="hidden" name="next" value="{{ next }}" /> -->
{% for field in form %}
{% if field.is_hidden %}
{{ field }}
{% else %}
{% if field.errors %}{{ field.errors }}{% endif %}
<p
{% if field.errors %} class="error"{% endif %}
{% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}
{% ifequal field.name "name" %} style="display:none;"{% endifequal %}
{% ifequal field.name "email" %} style="display:none;"{% endifequal %}
{% ifequal field.name "url" %} style="display:none;"{% endifequal %}
{% ifequal field.name "title" %} style="display:none;"{% endifequal %}>
<!-- {{ field.label_tag }} -->{{ field }}
</p>
{% endif %}
{% endfor %}
<p class="submit">
<button type="submit">Send</button>
<!-- <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" /> -->
</p>
</form>
そして、私が持っている食事と写真のページには:
<h4>Post a Message</h4>
{% render_comment_form for meal %}
<h4>Post a Message</h4>
{% render_comment_form for picture %}