I am following the tutorial in the book Django 4 for the Impatient and I’m getting TemplateDoesNotExist.
Here is the installed apps section of the settings.py file.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'movie',
'news',
]
The file that I am trying to load is news.html located in the Templates folder of the news app.
Here is the TEMPLATES declaration in settings.py.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'moviereviews/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',
],
},
},
]
Here is the entry in the urls.py entry for the main project folder.
urlpatterns = [
path('admin/', admin.site.urls),
path('', movieViews.home, name='home'),
path('about/', movieViews.about, name='about'),
path('signup/', movieViews.signup, name='signup'),
path('news/', include('news.urls')),
]
The news.html template is in news/templates. If I move this html page to the templates folder in the main project application, it finds the page. However, if I remove it from that templates folder I get the TemplateDoesNotExist error.
I compared my code, line-by-line with the code that I pulled from Github for the book and don’t see any differences, but clearly I am missing something here.
What could be missing that is preventing the file news/templates/news.html from being found?
I’ve been searching for answers but with no success, so I’m hoping someone here can shed some light on this for me.
Thanks in advance!!