我只是对 django 评论中的一个奇怪的属性感到好奇。当发表评论后(在/comments/post/),django 将重定向到 ?c="comment_pk"。来自 django 的评论库:
"""
Handle the "where should I go next?" part of comment views.
The next value could be a kwarg to the function (``default``), or a
``?next=...`` GET arg, or the URL of a given view (``default_view``). See
the view modules for examples.
Returns an ``HttpResponseRedirect``.
"""
next = data.get("next", default)
if next is None:
next = urlresolvers.reverse(default_view)
if get_kwargs:
if '#' in next:
tmp = next.rsplit('#', 1)
next = tmp[0]
anchor = '#' + tmp[1]
else:
anchor = ''
joiner = ('?' in next) and '&' or '?'
next += joiner + urllib.urlencode(get_kwargs) + anchor
return HttpResponseRedirect(next)
我只是好奇为什么 django 的制造商决定拥有这个。只是重定向回同一页面有什么问题?是否真的需要评论 pk 参数?在我看来不是。
此外,当我尝试将 httpresponse 修改为 '' 空字符串的值时,由于某些init期望 2 个参数错误,它不会让我这样做。如果这 ?c=pk 真的不需要,我怎样才能摆脱这个自动重定向参数?
谢谢!