跳至內容
選單
此問題已被標幟
3 回覆
23828 瀏覽次數

Hi Guys,

My requirement is to redirect from '/web/login' to homepage (website) if condition is True.

@http.route('/web/login', type='http', auth="none")  
def web_login(self, redirect=None, **kw):
     # ...................
     if condition:
         return werkzeug.utils.redirect('/')

     # ....................


but result is

if not redirect and request.params['login_success']:
KeyError: 'login_success'

and also tried return http.local_redirect('/')

Please help me.

頭像
捨棄
最佳答案

Hi you can check this: 




頭像
捨棄
最佳答案

if condition TRUE:

      return request.render(module_name.templateID1')  or request.redirect('/')

else:

     return request.render('web.login', values)

     

頭像
捨棄
最佳答案

Hi,

"KeyError" comes when dictionary has no key. Use request.params['login_success'] = False to define dict key.
I hope this helps you.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
10月 19
11267
0
5月 19
3657
0
6月 19
4273
1
10月 18
6255
2
7月 25
4650