When you can't call base.html in Django

What to do if you get angry with TemplateDoesNotExist by creating a common template in Django

It's a memo for myself because I'll forget it soon.

Status

--Create a templates directory directly under the project directory and create base.html in it --[TemplateDoesNotExist] error occurs when base.htnl is called from html directly under the templates directory in each application directory.

In the figure below, I want to call base.html from list.html

image.png

Django version

3.1.1

solution

In settings.py directly under the project directory import os 'DIRS': [os.path.join(BASE_DIR, 'templates')] Add

image.png

After that, in the html file you want to read base.html image.png

OK!

If you forget [import os] [name 'os' is not defined] I get angry.

Recommended Posts

When you can't call base.html in Django
When accessing from Andorid Chrome, Django CSRF validation fails or you can't log in
A solution when you can't start project Django on Windows
When you forget your admin screen username / password in Django
When you get a cannot assign module before Module.init () call in pytorch
When codec can't decode byte appears in python
Models in Django
[Django] Error when SlugField is specified in .filter ()
Display error message when login fails in Django
[Python] What to check when you get a Unicode Decode Error in Django
Until you create a new app in Django
Forms in Django
When you want to filter with Django REST framework
When you can't bash into an alpine image container
Until you run server Django in Visual Studio Code
Things to do when you start developing with Django
When you want to plt.save in a for statement
When you get an error in python scraping (requests)
[Note] I can't call the installed module in jupyter
What to do when you can't bind CaboCha to Python
Model changes in Django
[Django] A memorandum when you want to communicate asynchronously [Python3]
[Django 2.2] How do you display relation destinations in Django? [List View]
[Python version] Why can't you do object-oriented development in Java?
CSRF validation error when accessing django 3.0 admin page in Chrome
How to update user information when logging in to Django RemoteUserMiddleware
Check in advance what happens when you execute the command
I can't log in to the admin page with Django3
What to do when "Invalid HTTP_HOST header" appears in Django
What to do if you can't log in as root