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"
My code is :
def home(request):
return render(request,'/templates/home.html')
path of the file shown in this image
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),
]