簡體   English   中英

我應該在 settings.py 中寫什么來導入我的模板

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

我已經在 pythonanywhere 上部署了我的項目,但出現模板不存在的錯誤

在此處輸入圖像描述

它在本地主機上正常工作

文件目錄

在此處輸入圖像描述

設置.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',
            ],
        },
    },
]

有人可以告訴我應該添加什么我的模板 DIRS

嘗試將其放入 DIRS

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

之后,您可以獲得 html 文件,例如“Main/test.html”

是的,名字最好小寫

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM