开发者

Django comments change success url

开发者 https://www.devze.com 2023-03-25 10:03 出处:网络
I would like to change the URL you are redirected to when django posts a comment successfully - I\'d much rat开发者_运维问答her be taken to the page where the comment has been posted to, rather than t

I would like to change the URL you are redirected to when django posts a comment successfully - I'd much rat开发者_运维问答her 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消