从外部 html 文件扩展

extending from extenal html file

将 base.html 从 /blog/templates/base.html 扩展到 users/templates/users/register.html 中的用户应用:

我无法在用户应用程序中扩展 'blog/template/base.html'。

我使用这个代码:

{% extends "blog/base.html" %}

这是我的项目图片:

错误:

TemplateDoesNotExist at /register/

Blockquote

Blockquote

blog/base.html

Request Method: GET Request URL: http://localhost:8000/register/ Django Version: 2.2 Exception Type: TemplateDoesNotExist Exception Value:

blog/base.html

INSTALLED_APPS 中应用程序的顺序对于使用模板很重要。

来自 order of INSTALLED_APPS in Django 上的 Django 官方文档:

When several applications provide different versions of the same resource (template, static file, management command, translation), the application listed first in INSTALLED_APPS has precedence.

因此您的项目必须使用第一个模板文件夹。

您可以将 'base.html' 文件移动到父模板文件夹,或更改 INSTALLED_APPS 订单。