【问题标题】:Django Template DIRS TemplateDoesNotExist: Why are some templates being skipped (Skipped)?Django Template DIRS TemplateDoesNotExist:为什么有些模板会被跳过(Skipped)?
【发布时间】:2020-01-28 14:39:50
【问题描述】:

我正在试用django-scheduler 的示例项目。当我尝试加载 127.0.0.1 时,它会为 base.html 抛出 TemplateDoesNotExist。 Debug = True 说:

Django tried loading these templates, in this order:

Using engine django:

django.template.loaders.filesystem.Loader: D:\Code\django-calendar-sample\django-scheduler-sample\project_sample\templates\base.html (Skipped)
django.template.loaders.filesystem.Loader: D:\Code\django-calendar-sample\django-scheduler-sample\project_sample\templates\base.html (Skipped)
django.template.loaders.app_directories.Loader: C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\auth\templates\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\admin\templates\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\ProgramData\Anaconda3\lib\site-packages\debug_toolbar\templates\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: D:\Code\django-calendar-sample\django-scheduler-sample\project_sample\templates\base.html (Skipped)

注意它显示的前两行的最后(base.html 实际存在的地方)(已跳过)。为什么他们被跳过了?

【问题讨论】:

  • 你有一个递归错误。 django-scheduler-sample\project_sample\templates\base.html 本身会尝试扩展 base.html,除非您提供一个单独的base.html,否则它可以从其扩展。

标签: python django django-scheduler


【解决方案1】:

谢谢@solarissmoke,你是对的;

base.html:

{% extends "base.html" %}
{% load i18n %}
{% block extra_head %}
{{ block.super }}
{% endblock %}

{% block rtab_id %}id="schedule_tab"{% endblock %}

{% block subnav %}
<ul>
    {% if user.is_authenticated %}
        <li><a href="">{% trans "Create a Calendar" %}</a></li>
        <li><a href="">{% trans "Your Calendars" %}</a></li>
    {% endif %}

        <li><a href="">{% trans "All Calendars" %}</a></li>
    </ul>
{% endblock %}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    相关资源
    最近更新 更多