這是目前項(xiàng)目的結(jié)構(gòu)。webbshop templates webbshop base.html settings.pyhome templates home index.html在我的“webbshop”設(shè)置中,這是我獲得設(shè)置的“主”應(yīng)用程序。但是當(dāng)我嘗試用 index.html 擴(kuò)展 base.html 時,我收到了這個錯誤:django.template.exceptions.TemplateDoesNotExist: webbshop/base.html"在頁面上它顯示了這一點(diǎn)。 https://i.stack.imgur.com/QUQbd.png它似乎沒有去 webbshop 應(yīng)用程序中尋找模板。我四處搜尋,應(yīng)該可以。這是我的 index.html{% extends 'webbshop/base.html' %}{% block content %}hey{% endblock %}這些是我在 webbshop 應(yīng)用程序中安裝的應(yīng)用程序。INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'home',]解決了!解決方案:即使我在 webbshop 應(yīng)用程序中有 settings.py 文件,我仍然必須將“webbshop”添加為已安裝的應(yīng)用程序。否則它將無法識別該應(yīng)用程序中的模板。
Django 無法擴(kuò)展到另一個應(yīng)用程序中的模板
繁華開滿天機(jī)
2022-10-06 16:04:03