1
我正在使用自定義模板標籤,它調用另一個標籤,具體取決於它是哪個小時。調用另一個使用@ register.inclusion_tag的模板標籤
@register.simple_tag(takes_context=True)
def my_custom_template_tag(context):
"""
"""
now = datetime.now()
# if the current hour:minute is less than
# the publication switch settings defined hour
if now.strftime('%H:%M') <= settings.PUBLICATION_SWITCH_TIME:
print now.strftime('%H:%M')
return my_other_template_tag(context)
else:
pass
@register.inclusion_tag('my_other_template_tag_template_path', takes_context=True)
def my_other_template_tag(context):
"""
"""
return {
'foo'
}
的問題是,my_custom_template_tag似乎忽視了所謂的 「my_other_template_tag」 @inclusion_tag。有沒有辦法做到這一點,同時保持使用@inclusion_tag?
謝謝!