gpt4 book ai didi

python - flask登录中如何实现localize_callback

转载 作者:太空宇宙 更新时间:2023-11-04 03:12:22 25 4
gpt4 key购买 nike

我看到了官方文档,它没有任何关于回调的细节。

http://flask-login.readthedocs.io/en/latest/

By default, the LoginManager uses flash to display messages when a user is required to log in. These messages are in English. If you require localization, set the localize_callback attribute of LoginManager to a function to be called with these messages before they’re sent to flash, e.g. gettext. This function will be called with the message and its return value will be sent to flash instead.

我尝试使用

@login_manager.localize_callback
def localize_callback():
return 'local string'

当我这样做的时候。它告诉我

TypeError: 'NoneType' object is not callable

这里有什么问题?

最佳答案

我稍微调整了代码。虽然不合适但它可以工作

def localize_callback(*args, **kwargs):
return 'local string'
login_manager.localize_callback = localize_callback

关于python - flask登录中如何实现localize_callback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37605686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com