美文网首页
django TemplateDoesNotExist

django TemplateDoesNotExist

作者: 咕嘟咕嘟li | 来源:发表于2020-05-07 14:29 被阅读0次
项目目录如下: image.png
image.png
TemplateDoesNotExist at /
base.html
Request Method: GET
Request URL:    http://wanghongli.top:3000/
Django Version: 2.1.8
Exception Type: TemplateDoesNotExist
Exception Value:    
base.html
Exception Location: /usr/local/lib/python3.7/site-packages/django/template/loader.py in get_template, line 19
Python Executable:  /usr/bin/python
Python Version: 3.7.2
Python Path:    
['/root/fileshare',
 '/usr/local/lib/python37.zip',
 '/usr/local/lib/python3.7',
 '/usr/local/lib/python3.7/lib-dynload',
 '/root/.local/lib/python3.7/site-packages',
 '/usr/local/lib/python3.7/site-packages']
Server time:    Thu, 7 May 2020 11:58:40 +0800

django.template.loaders.filesystem.Loader: /fileshare/templates/base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/admin/templates/base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/auth/templates/base.html (Source does not exist)

setting.py修改:

...
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'fileshare/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',
            ],
        },
    },
]

django Unicode error hint

文件里不要出现乱码就可以解决该错误了

相关文章

网友评论

      本文标题:django TemplateDoesNotExist

      本文链接:https://www.haomeiwen.com/subject/fwwoghtx.html