【发布时间】:2017-12-27 08:57:45
【问题描述】:
django 1.11.3
我有一个模板不存在错误,据我所知,我的模板目录设置正确。 fleetdb 是我项目中的一个应用程序,具有以下目录结构:
+ fleetdb
+templates
+fleetdb
-index.html
-base.html
(other html pages)
直到我在索引中尝试 {% extends 'base.html' %} 之前一切正常:
{% extends 'base.html' %}
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'fleetdb/lists.css' %}" />
{% if vehicles_list %}
<ul>
{% for vehicle in vehicles_list %}
<li><a href="{% url 'fleetdb:detail' vehicle.id %}">{{ vehicle.unit }} {{ vehicle.make }} {{ vehicle.vmodel }} {{vehicle.color}}</a></li>
</ul>
{% endfor %}
{% else %}
<p>No Vehicles are available.</p>
{% endif %}
在我的 settings.py 中,我有一个 print(TEMPLATES) 语句,这一切似乎都在寻找正确的区域,但没有找到 base.html。在 pastebin 跟踪:https://pastebin.com/raw/MQDAip64
附带问题:我如何从另一个应用程序继承模板,会不会像 {% url 'fleetdb:detail' } 的 url 标签一样?
【问题讨论】: