【问题标题】:Django 'next' not working?Django“下一个”不起作用?
【发布时间】:2011-04-15 12:43:49
【问题描述】:

不知道这里出了什么问题。我正在使用内置的评论表单。表单标签是这样的:

<form action="{% comment_form_target %}?next={% url post post.id %}" method="post">

生成的 HTML 如下所示:

<form action="/comments/post/?next=/6/" method="post">

/6/ 是我的帖子的 post_detail 地址。但是我仍然在这个 URL 结束:

http://localhost:8000/comments/posted/?c=4

有一个

感谢您的评论。 留言

这里发生了什么?谢谢!

【问题讨论】:

    标签: django next django-comments


    【解决方案1】:

    next 应该是 POST 参数,而不是 GET 参数。 尝试将以下行添加到您的表单中

     <input type="hidden" name="next" value="{% url post post.id %}" />
    

    并将表单的操作保留为"{% comment_form_target %}"

    【讨论】:

    • 谢谢!那行得通。多么奇怪。我从教程中复制了该代码。我想这毕竟是不正确的。
    猜你喜欢
    • 2020-12-18
    • 2015-07-24
    • 2015-03-08
    • 1970-01-01
    • 2015-05-25
    • 2017-06-12
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多