Modify the template_dirs value in settings. py.
Annotations provided by Django are described as follows:
# Put strings here, like "/home/html/django_templates" or "C:/www/Django/templates ".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
That is to say, Django does not recommend using relative paths.
How can I load Templates using relative paths when deploying them to a site?
You can use the following method:
Import OS. Path
Template_dirs = (
OS. Path. Join (OS. Path. dirname (_ file _), 'templates'). Replace ('\\','/'),
)
In this case, the path that Django will load is under the directory where the settings. py file is located.Templates folder.
For example, my site deployment is as follows:
You only need to make a slight modification:
Import OS. Path
Template_dirs = (
OS. Path. Join (OS. Path. dirname (_ file _), '../templates'). Replace ('\\','/'),
)