Template Error

Im Created Index.html file in home app and views.py code is:

from django.shortcuts import render
# Create your views here.
def Home(request):
    return render(request, "home/index.html")

Error is:
**Internal Server Error: /home/
Traceback (most recent call last):
File “C:\Users\ASUS\Desktop\beta\web\django-website\Lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ASUS\Desktop\beta\web\django-website\Lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ASUS\Desktop\beta\web\beta\home\views.py”, line 4, in Home
return render(request, “home/index.html”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ASUS\Desktop\beta\web\django-website\Lib\site-packages\django\shortcuts.py”, line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ASUS\Desktop\beta\web\django-website\Lib\site-packages\django\template\loader.py”, line 61, in render_to_string
template = get_template(template_name, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\ASUS\Desktop\beta\web\django-website\Lib\site-packages\django\template\loader.py”, line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: home/index.html
[23/Nov/2023 10:14:49] “GET /home/ HTTP/1.1” 500 79225

How To fix?

To provide a definite answer, we need the tree structure of your Django project.

Depending upon your TEMPLATES settings, your template would generally belong in either /project_home/home/tempates/home/index.html or it might be in /project_home/templates/home/index.html.

The full error in the browser shows you the directories being searched, that’ll show you where you’re currently configured to look for template files.

1 Like