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?
谢谢!