How can I redirect after POST in Pyramid?

前端 未结 6 1549
花落未央
花落未央 2021-02-04 03:50

I\'m trying to have my form submit to a route which will validate the data then redirect back to the original route.

For example:

  • User loads the page websi
6条回答
  •  情深已故
    2021-02-04 04:00

    The Pyramid documentation has content about Redirect, you can see more information in below link :

    Pyramid documentation

    import pyramid.httpexceptions as exc
    raise exc.HTTPFound(request.route_url("section1"))   # Redirect
    

    Edited: Actually you can do that on client side with Javascript, first you should send particular response to client side(either with flashes some data or return Response object):

    window.location = '{{ request.route_path("route_name") }}';
    

提交回复
热议问题