TemplateDoesNotExist at Django python issue

I am new to Python and trying work on Django framework! as a basic I am trying to fetch values from HTML but I am getting the error "TemplateDoesNotExist at"

enter image description here

My code is :

def home(request):
   return render(request,'/tempaltes/home.html')

path of the file shown in this image

enter image description here

is i am giving wrong path ?

Register your template folder inside Setting.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Register your app inside Setting.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'Your App Name',
]

Set your App urls inside urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('app/', include('app.urls')),  # Your App url
]

Set your urls path inside urls.py of your App

from django.urls import path
from . import views

urlpatterns = [
    path('app/home', views.homeView),
 
]

you've misspelled templates in your path in views.py.

Also typically you want to have your templates inside your specified app's folder (e.g. playground/templates/home.html) if you move this folder it should look like this:

in /views.py:

def home(request):

return render(request,'home.html')

in urls.py:

from <appname>.views import home
urlpatterns = [
path("", home, name = "home"), ...
]

This will make it so your site opens up to home.html

Back to Top