使用Django版本2.2.3时出现“ TemplateDoesNotExist”错误

时间:2019-08-01 11:03:48

标签: django

我正在学习Django并建立一个页面。我收到TemplateDoesNotExist错误。我不知道该如何解决,但是我不知道要显示代码的哪些部分。

TemplateDoesNotExist at /
Leaning_logs/base.html
Request Method: GET
Request URL:    http://localhost:8000/
Django Version: 2.2.3
Exception Type: TemplateDoesNotExist
Exception Value:    
Leaning_logs/base.html
Exception Location: D:\learning-note\ll_env\lib\site-packages\django\template\backends\django.py in reraise, line 84
Python Executable:  D:\learning-note\ll_env\Scripts\python.exe
Python Version: 3.7.3
Python Path:    
['D:\\learning-note',
 'C:\\Users\\qingting_bailihua\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
 'C:\\Users\\qingting_bailihua\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
 'C:\\Users\\qingting_bailihua\\AppData\\Local\\Programs\\Python\\Python37\\lib',
 'C:\\Users\\qingting_bailihua\\AppData\\Local\\Programs\\Python\\Python37',
 'D:\\learning-note\\ll_env',
 'D:\\learning-note\\ll_env\\lib\\site-packages']
Server time:    Thu, 1 Aug 2019 10:45:39 +0000

1 个答案:

答案 0 :(得分:0)

myapp/views.py

class ContractsView(TemplateView):
    def get(self, request):
        return render(request, 'yourPage.html')

在项目文件夹的urls.py中,将该URL从应用程序文件夹添加到view.py类中。

project/urls.py

urlpatterns = [
.
path('contractList/', ContractsView.as_view(), name='contractsList'),
.
]

如果我没有帮助您。在这里,您将找到更多答案: Django TemplateDoesNotExist?