djangoforbeginners icon indicating copy to clipboard operation
djangoforbeginners copied to clipboard

chapter 3- Pages app-TemplateDoesNotExist at / home.html

Open UncleQA opened this issue 3 years ago • 4 comments
trafficstars

I am getting the error 'TemplateDoesNotExist at / home.html' with the following TEMPLATE setting in settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / 'templates'],

The template folder is in project level. Can you please help ? Capture

UncleQA avatar Jun 18 '22 18:06 UncleQA

Capture2

UncleQA avatar Jun 18 '22 18:06 UncleQA

Hey Uncle,

I am using the 3.1 edition book, and this is what I do. Move your template folder up 1. I might be reading your files wrong, but I do not nest the template folder in the Django config folder. I added a random project example. Hope it helps

'DIRS': [str(BASE_DIR.joinpath('templates'))],

Screen Shot 2022-06-21 at 8 39 32 AM ,

susbot avatar Jun 21 '22 14:06 susbot

How will it look in the Pages app, chapter 3.Have you placed the templates folder in the app or project folder? I does not work for me from the project folder

UncleQA avatar Jun 21 '22 18:06 UncleQA

Hey Uncle,

Once again, my advice is based on what I did in 3.1 so I can't speak on behalf of chapter 3, for the 4.0 book. The template folder should be in your Top Root Project folder called "PAGES. From what I can tell in the screenshot you have it nested inside "Django_project" which looks like your Django config settings. You can trying taking it out and moving it up 1 directory. It will sit next to your "Django_project" Folder

So try moving templates folder up 1 directory, and then use 'DIRS': [str(BASE_DIR.joinpath('templates'))],

Screen Shot 2022-06-21 at 4 11 29 PM

susbot avatar Jun 21 '22 22:06 susbot

I'm closing this now. The correct answer is provided by @susbot. The later versions of the book use django_project in place of config but the key is that the templates directory be at the project-level as @susbot shows in the screen shot.

wsvincent avatar Aug 22 '22 17:08 wsvincent