【发布时间】:2020-07-26 08:25:25
【问题描述】:
我的 django 项目在 localhost 中完美运行。
我正试图在 Ubuntu-Apache 上部署它。
我做了 git clone
我得到了这个错误
TemplateDoesNotExist at /
嗯?我注意这个错误信息
django.template.loaders.filesystem.Loader: /templates/base_layout.html (Source does not exist)
这个错误来自
{% extends 'base_layout.html'%} (/home/ubuntu/django/blog/djangonautic/articles/templates/articles/article_list.html)
我希望 Django 在父文件夹 ({root}/templates) 中搜索模板。
它的正确路径是
/home/ubuntu/django/blog/djangonautic/templates/base_layout.html
(我检查了文件在那里)
为什么我的 Django 不在(根)模板中寻找它?
在 settings.py 中
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates', 'front/build'],
...
我猜是因为。
- 虚拟环境
我在 Ubuntu 中创建的(不是在本地创建的) - Apache 配置
我关注了https://medium.com/saarthi-ai/ec2apachedjango-838e3f6014ab 这个帖子。 - settings.py 中有问题
但我不认为这是错误的,因为在本地它运作良好......
有什么需要调试的告诉我,我会尽快回复
已解决
添加os.path.join 并工作...
【问题讨论】:
标签: django apache ubuntu deployment django-templates