Skip to content

Commit

Permalink
[1.0.X] Fixed #9268: pass the "next" param through in the comment pre…
Browse files Browse the repository at this point in the history
…view/post view. Also updated the docs to make this a bit clearer. Backport of r10418 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10419 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jacobian committed Apr 7, 2009
1 parent 4c7b2b8 commit a340c7f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions django/contrib/comments/templates/comments/form.html
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load comments i18n %} {% load comments i18n %}
<form action="{% comment_form_target %}" method="post"> <form action="{% comment_form_target %}" method="post">
{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
{% for field in form %} {% for field in form %}
{% if field.is_hidden %} {% if field.is_hidden %}
{{ field }} {{ field }}
Expand Down
1 change: 1 addition & 0 deletions django/contrib/comments/templates/comments/preview.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{% block content %} {% block content %}
{% load comments %} {% load comments %}
<form action="{% comment_form_target %}" method="post"> <form action="{% comment_form_target %}" method="post">
{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
{% if form.errors %} {% if form.errors %}
<h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1> <h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
{% else %} {% else %}
Expand Down
1 change: 1 addition & 0 deletions django/contrib/comments/views/comments.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def post_comment(request, next=None):
template_list, { template_list, {
"comment" : form.data.get("comment", ""), "comment" : form.data.get("comment", ""),
"form" : form, "form" : form,
"next": next,
}, },
RequestContext(request, {}) RequestContext(request, {})
) )
Expand Down
14 changes: 12 additions & 2 deletions docs/ref/contrib/comments/index.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To get started using the ``comments`` app, follow these steps:
#. Use the `comment template tags`_ below to embed comments in your #. Use the `comment template tags`_ below to embed comments in your
templates. templates.


You might also want to examine the :ref:`ref-contrib-comments-settings` You might also want to examine :ref:`ref-contrib-comments-settings`.


Comment template tags Comment template tags
===================== =====================
Expand Down Expand Up @@ -166,7 +166,7 @@ A complete form might look like::
</form> </form>


Be sure to read the `notes on the comment form`_, below, for some special Be sure to read the `notes on the comment form`_, below, for some special
considerations you'll need to make if you're using this aproach. considerations you'll need to make if you're using this approach.


.. templatetag:: comment_form_target .. templatetag:: comment_form_target


Expand All @@ -180,6 +180,16 @@ you'll always want to use it like above::


<form action="{% comment_form_target %}" method="POST"> <form action="{% comment_form_target %}" method="POST">


Redirecting after the comment post
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To specify the URL you want to redirect to after the comment has been posted,
you can include a hidden form input called ``next`` in your comment form. For example::

<input type="hidden" name="next" value="{% url my_comment_was_posted %}" />

.. _notes-on-the-comment-form:

Notes on the comment form Notes on the comment form
------------------------- -------------------------


Expand Down

0 comments on commit a340c7f

Please sign in to comment.