1
我想在密碼過期時將用戶重定向到更改密碼頁面。我已經設置了一個接收用戶的RequestFactory。我在哪裏把重定向部分放在金字塔裏?如何檢查金字塔中的每個請求以重定向?
我想在密碼過期時將用戶重定向到更改密碼頁面。我已經設置了一個接收用戶的RequestFactory。我在哪裏把重定向部分放在金字塔裏?如何檢查金字塔中的每個請求以重定向?
我不確定要理解您的問題,但在金字塔中重定向的常用方法是在視圖函數中返回一個HTTPFound實例。我認爲你也可以提高它,因爲這是一個例外。
from pyramid.httpexceptions import HTTPFound
def my_view(request):
return HTTPFound('/new/location/to/redirect')
一個好的做法是使用route_url
建設要重定向到URL。