1

I'm learning Django and building a page. I get the TemplateDoesNotExist error. I don't know how to fix this, But I don't know which parts of the code to show.

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
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Bai
  • 11
  • 1
  • Which ever URL you are trying to load check the function of that URL. After that check that function, in the function check that the HTML you are trying to reference actually exists inside of your templates folder or not. – Talha Murtaza Aug 01 '19 at 11:06
  • base.html doesn't exist or maybe you are referencing it wrong – Talha Murtaza Aug 01 '19 at 11:07
  • Please show the layout of the files in your project, including the template you want to use. Also show `TEMPLATES` from your `settings.py`, and the view that is failing. – Alasdair Aug 01 '19 at 11:10
  • Is `Leaning_logs/base.html` correct? Should it be something like `Learning_logs/base.html` instead? – Alasdair Aug 01 '19 at 11:11

1 Answers1

0
myapp/views.py

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

In the urls.py in your project folder add the url to your view.py class from application folder.

project/urls.py

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

If I did not manage to help you. Here you will find more answers: Django TemplateDoesNotExist?

helenko11
  • 11
  • 4