你不能那样做。但是,您可以设置一个变量,并使用该变量来选择要扩展的模板:
{% extends my_template %}然后在python代码中编写类似以下内容的代码:
if ajax: template_values['my_template'] = 'base_ajax.html'else: template_values['my_template'] = 'base.html'
您可能希望参考文档以获取更多信息。

你不能那样做。但是,您可以设置一个变量,并使用该变量来选择要扩展的模板:
{% extends my_template %}然后在python代码中编写类似以下内容的代码:
if ajax: template_values['my_template'] = 'base_ajax.html'else: template_values['my_template'] = 'base.html'
您可能希望参考文档以获取更多信息。