0
Guys, starting to study Python with Django now and a doubt has arisen here that I can not solve.
django.template.exceptions.TemplateDoesNoteExist: home.html
Views.py
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home(request):
return render(request, 'home.html')
urls.py
from django.contrib import admin
from django.urls import path
from simplemooc.core import views as views_core
urlpatterns = [
path('', views_core.home, name='home'),
path('admin/', admin.site.urls),
]
py Settings.
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 't1y1m8wwub+br!*1)d4k#$$we^ceqw78ufc-t)&pn5j4=tny*_'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'simplemooc.core',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'simplemooc.urls'
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',
],
},
},
]
'''TEMPLATE_DIRS = [
'simplemooc/core/template',
]'''
WSGI_APPLICATION = 'simplemooc.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
I’m following a course, I’ve made some changes for the difference of versions, but this part I’m not able to solve.
Hello @Victor, I made an issue in your reply, see if it represents your intention if you can’t reverse it here =D
– Icaro Martins
Thanks for fixing @Icaromartins forgot to format.
– Victor Fernandes