I'm struggling to get the following working:
I would like to have a 'general' templates folder for non-app-specific html in the directory of my project, akin to the static folder for non-app-specific static files.
My current structure looks like this:
|- my_app/ |- dashboard/ |- static |- dashboard/ |- css/ |- ... |- templates |- dashboard |- index.html |- ... |- urls.py |- views.py |- landing/ |- static |- landing/ |- css/ |- ... |- templates |- landing |- index.html |- ... |- urls.py |- views.py |- my_app/ |- static/ |- my_app/ <-- no problem loading these |- css/ |- ... |- templates |- my_app <-- unable to load these |- boilerplate.html |- settings.py |- ... |- manage.py My current convention is that if the html or static files are in an app directory, they are specific to that app, if they are in the project (here my_app) directory, they are applicable across the whole project.
My problem now is that when I try to load boilerplate.html (a snippet) into dashboard/index.html by stating {% include "my_app/boilerplate.html" %} in dashboard/index.html, it complains with:
TemplateDoesNotExist at /dashboard
My settings.py file, or at least the part I believe to be relevant is the following:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, '/my_app/templates').replace('\\', '/'), ], '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', ], }, }, ] Something is most likely missing or wrongly configured as it is not working, but I cannot figure out what it is. Any ideas?