简体   繁体   English

我应该在 settings.py 中写什么来导入我的模板

[英]what should i write in the settings.py to import my Template

I have deployed my project on pythonanywhere and there i am getting an error that template does not exist我已经在 pythonanywhere 上部署了我的项目,但出现模板不存在的错误

在此处输入图像描述

It's working properly on local host它在本地主机上正常工作

File directory文件目录

在此处输入图像描述

settings.py设置.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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',
            ],
        },
    },
]

Can someone tell what should i add my template DIRS有人可以告诉我应该添加什么我的模板 DIRS

Try to put this into DIRS尝试将其放入 DIRS

'DIRS': [os.path.join(BASE_DIR, 'Templates')],

after that you can get your html files like 'Main/test.html'之后,您可以获得 html 文件,例如“Main/test.html”

And yeah it's better to put names in lowercase是的,名字最好小写

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM