I'm following a video tutorial but Im getting an error. The only differance is that author uses Subline Text, while i use VSCode what is causing the error? enter image description here
here's my views code:
from django.http import HttpResponse
from django.shortcuts import render
def about(request):
return HttpResponse("Inforamation about")
def home(request):
return render(request, 'home.html')
here's my urls code:
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('about/', views.about),
path('home/', views.home),
]
and my settings code:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['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',
],
},
},
]
CodePudding user response:
Update the directory path to use full path:
'DIRS': [os.path.join(BASE_DIR, 'templates')],
CodePudding user response:
You should start by changing your folder structure. Your folder structure for the templates should look like this:
mysite
----|templates
----|mysite
----|home.html
After that, change your template path from 'home.html'
to 'mysite/home.html'
.