0
嗨,我是新來的燒瓶,我有一個問題。app_context_processor發生對象在燒瓶中無法對接
我做了template_functions.py
使用功能藍圖模板象下面這樣:
template_functions.py:
@my_bp.app_context_processor
def get_today_date():
return str(datetime.date.today())
藍圖應用的__init__.py
:
my_bp = Blueprint(~~~~)
from template_functions.py import *
test.html
{{ get_today_date }}
但應用程序時出現object is not callable error
當我註冊get_today_date爲應用背景處理器
我已經改變了@my_bp.app_context_processor
到@my_bp.context_processor
,但什麼是發生了。我如何使用它們?
你的主應用程序('app = Flask(~~~)')定義在哪裏?您是否將藍圖「my_bp」註冊到主應用程序中? –
@AshokaLella當然,藍圖運行良好,沒有app_context_prosessor –
@AshokaLella我的應用程序的所有東西運行良好,唯一的問題是app_context_processor不能很好地工作 –