Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
23816 Zobrazení

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.

Avatar
Zrušit
Nejlepší odpověď

Hi you can check this: 




Avatar
Zrušit
Nejlepší odpověď

if condition TRUE:

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

else:

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

     

Avatar
Zrušit
Nejlepší odpověď

Hi,

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
říj 19
11265
0
kvě 19
3648
0
čvn 19
4269
1
říj 18
6248
2
čvc 25
4638