Reputation: 7873
I have encountered interesting problem on Django 2.
In my settings.py
I have written this:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(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',
],
},
},
]
After that I have created folder templates
in my projects root folder.
Then I have created app with name front
and added it into my settings.py
INSTALLED_APPS
:
Inside my views.py
I have added this view:
def index(request):
return render(request, 'front/index')
I have assigned its url like this:
url(r'^$', views.index, name='index'),
When I'm trying to access to this view I get this error:
TemplateDoesNotExist at /
front/index
Why this happening? Did I miss something?
Upvotes: 2
Views: 1040
Reputation: 27513
Change
def index(request):
return render(request, 'front/index')
to
def index(request):
return render(request, 'front/index.html')
Upvotes: 8