K
K
Konstantin Malyarov2018-08-12 18:21:02
Django
Konstantin Malyarov, 2018-08-12 18:21:02

Why does not see templates?

Structure:
5b704f79253d9135239716.png
settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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',
            ],
        },
    },
]

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

urlpatterns = [
    path('admin/', admin.site.urls),
    path('home/', include('home.urls')),
]

urls.py
from django.urls import path
from home import views

urlpatterns = [
    path('', views.index, name='index'),
]
views.py

from django.shortcuts import render

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

Error - cannot find template:
5b70505d469ae836972286.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2018-08-12
@netpastor

Tell Django to start looking for templates in the templates folder
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, '..' , 'templates'),],
'APP_DIRS': True,
Something like this
https://docs.djangoproject.com/en/dev/ref/settings...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question