跳至内容
菜单
此问题已终结
3 回复
23600 查看

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
11081
0
5月 19
3504
0
6月 19
4095
1
10月 18
6083
2
7月 25
4191