模板网站怎么在服务器上运行,模板在部署服务器上正确呈现,但在运行时出现TemplateDoesNotExist错误...

我有一个这样的项目结构mainproject

├── manage.py

├── mainproject

│   ├── settings.py

│   ├── templates

│   │   └── mainproject

│   │   └── index.html

│   ├── urls.py

│   ├── views.py

│   └── wsgi.py

└── app

├── admin.py

├── apps.py

├── forms.py

├── models.py

├── templates

│   └── app

│   ├── index.html

│   └── abc.html

├── urls.py

└── views.py

现在在我的设置.py我有TEMPLATES = [

{

'BACKEND': 'django.template.backends.django.DjangoTemplates',

'DIRS': ['mainproject/templates', 'app/templates'],

'APP_DIRS': True,

'OPTIONS': {

'context_processors': [

'django.template.context_processors.debug',

'django.template.context_processors.request',

'django.contrib.auth.context_processors.auth',

'django.contrib.messages.context_processors.messages',

],

},

},

]

当我在部署服务器的主域上使用它时(使用nginx和uwsgi部署),它工作得很好。你知道吗

我可以访问mainproject在domain.com的索引和app在domain.com/app的索引

但是当使用runserver时,只有domain.com:8000/app起作用,domain.com:8000给出错误TemplateDoesNotExist at /。你知道吗

为什么会这样?如何解决?你知道吗

模板加载程序验尸:Using engine django:

django.template.loaders.filesystem.Loader: /home/mohit/mainproject/templates/mainproject/index.html (Source does not exist)

django.template.loaders.filesystem.Loader: /home/mohit/app/templates/mainproject/index.html (Source does not exist)

django.template.loaders.app_directories.Loader: /home/mohit/Env/mainproject/lib/python2.7/site-packages/django/contrib/admin/templates/mainproject/index.html (Source does not exist)

django.template.loaders.app_directories.Loader: /home/mohit/Env/mainproject/lib/python2.7/site-packages/django/contrib/auth/templates/mainproject/index.html (Source does not exist)

django.template.loaders.app_directories.Loader: /home/mohit/mainproject/app/templates/mainproject/index.html (Source does not exist)

如果我在TEMPLATES中更改DIRS行设置.py并且成功了'DIRS': ['mainproject/mainproject/templates', 'app/templates'],

然后它在runserver上工作,而在部署服务器上不工作。你知道吗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值