Django中Template does not exit

在template下新建了一个html文件,运行时一直报错

原因是,在运行时django一直在找自己默认路径下的模板,找不到我自己建的html文件

在settings.py中添加如下代码:

TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates').replace('\', '/'),
)
就会发现运行成功了。
原文地址:https://www.cnblogs.com/1998lu/p/9129655.html