So I am trying to open a template from…
But the template file is not shown as below…
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request, "home/index.html")
Weird thing is that my webpage still works, and when I delete that function it does not.
Here is some additional Info…
settinbgs.py
# Application definition
INSTALLED_APPS = [
'project_long_page',
'about',
'home',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
home/urls.py
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
]
>Solution :
Your templates folder should be within your app folder home (under about), otherwise Django won’t find it. Check out https://django-project-skeleton.readthedocs.io/en/latest/structure.html for the proper file structure. My guess is the same could be said for the other folders withing your templates folder. You can have a templates folder in your root, but I don’t think this is what you will need in your case.



