Redirect 通过HTTPFound重定向未传递的参数

Redirect 通过HTTPFound重定向未传递的参数,redirect,pyramid,Redirect,Pyramid,我有一个使用URL dispatch的金字塔应用程序。我有一个路由“/delete”,它从数据库中删除记录并重定向到视图。当重定向发生时,我希望视图重新加载到同一页上。我正在使用webhelpers.paginate进行分页。问题是,当发生重定向时,不会传递参数 删除路由: @view_config(route_name='delete') def delete(request): # Get the current page, the page title, and the id of

我有一个使用URL dispatch的金字塔应用程序。我有一个路由“/delete”,它从数据库中删除记录并重定向到视图。当重定向发生时,我希望视图重新加载到同一页上。我正在使用webhelpers.paginate进行分页。问题是,当发生重定向时,不会传递参数

删除路由:

@view_config(route_name='delete')
def delete(request):
    # Get the current page, the page title, and the id of the record to delete
    current_page = int(request.params.get('page', 1))

    # Database transactions
    ...
    # Reload the view
    url = request.route_url(route_name='records', app_name='BLAH', userid='BLAH', page=current_page)
    return HTTPFound(location=url)
记录视图:

@view_config(route_name='records', renderer='records.jinja2')
def records(request):
    # Get the current page
    current_page = int(request.params.get('page', 1))
加载记录视图时,不会传递参数,并且为当前页面设置默认值“1”。应用程序名称和用户id的“BLAH”值也不会传递

我注意到的一点是,视图似乎加载了两次,但我不知道如何确认这一点。我认为页面被加载了两次,因为在重定向之后我看到两个对数据库的调用


我错过了什么?谢谢。

当您的
在删除路由中打印url
时,url是什么?路由
记录了什么定义?
如果你想要一个GET,你应该试试关键字参数
\u查询

url = request.route_url(name='records', _query=(('page', current_page),))

查看浏览器的开发人员工具以查看请求的发生情况。在Chrome中,如果有帮助的话,你可以“在导航时保留日志”。此外,您还可以在两个视图函数中添加
print('stuff')
。此外,请参见以下答案: