3

I would like to change the URL you are redirected to when django posts a comment successfully - I'd much rather be taken to the page where the comment has been posted to, rather than the current redirect to a 'thanks for your comment' URL. Is there a place I can override this in django? Thanks

jvc26
  • 6,363
  • 6
  • 46
  • 75
  • possible duplicate of [Django: Redirect to current article after comment post](http://stackoverflow.com/questions/2123206/django-redirect-to-current-article-after-comment-post) – miku Jul 31 '11 at 15:33

1 Answers1

6

Just add a hidden field called next to your comment form with the value of the url you'd like to re-direct to after the form has been posted.

Example from the docs:

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

https://docs.djangoproject.com/en/dev/ref/contrib/comments/#redirecting-after-the-comment-post

rolling stone
  • 12,668
  • 9
  • 45
  • 63