python - 未找到模板(路径设置为 setting.py 模板)
问题描述
嘿,我是 Django 的新手,我的第一个项目几乎完成了,但是当我heroku open
在终端中使用 Heroku 打开我的网站时遇到问题,当网站打开时,我收到一个错误,提示我的基本模板丢失。
设置
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
任何 html
{% extends "learning_logs\base.html" %}
.........
错误
TemplateDoesNotExist at /
learning_logs\base.html
django.template.loaders.filesystem.Loader: /app/templates/learning_logs\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/learning_logs/templates/learning_logs\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/users/templates/learning_logs\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.7/site-packages/bootstrap4/templates/learning_logs\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.7/site-packages/django/contrib/admin/templates/learning_logs\base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.7/site-packages/django/contrib/auth/templates/learning_logs\base.html (Source does not exist)
如果任何其他代码可能有帮助,请告诉我。
解决方案
还不能评论,所以我会在回复中提到:
Windows 系统使用反斜杠“\”来表示文件夹/目录的变化,而其他系统使用正斜杠“/”。Heroku 有 linux 服务器,无法识别正斜杠
推荐阅读
- php - Themosis 框架收集循环 - WordPress
- tomcat - Tomcat 服务器 - 这是一个代理服务器。不响应非代理请求
- python - 更改日期和时间的格式
- regex - 通过扩展现有的正则表达式在匹配中匹配
- c# - 是否可以在同一端口上的 HTTP 中创建另一个端点?
- excel - 简化重复代码的方法
- aurelia - 我如何在 Aurelia 中将函数设为全局
- c# - 如何改进从 List 映射到 ModelRequest 的代码
- javascript - Javascript - 我可以让这个表格滚动到顶部吗?
- wordpress - How to add block content in the cutsom gutenberg block