Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
23810 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi you can check this: 




Awatar
Odrzuć
Najlepsza odpowiedź

if condition TRUE:

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

else:

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

     

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 19
11262
0
maj 19
3636
0
cze 19
4263
1
paź 18
6245
2
lip 25
4631