Django - 从父目录扩展模板

int*_*_32 3 django django-templates

我有这个模板结构:

dir1:base.html dir2:template.html

template.html必须扩展base.html:

{% extends '../dir1/base.html' %}
Run Code Online (Sandbox Code Playgroud)

但它引发了错误:

渲染时抓住TemplateDoesNotExist:../ dir1/base.html

gru*_*czy 7

您应该在settings.py中设置模板目录(https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs),然后使用{% extends 'dir/base.html' %}.