Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
23801 Переглядів

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.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
жовт. 19
11256
0
трав. 19
3633
0
черв. 19
4260
1
жовт. 18
6243
2
лип. 25
4624