What is the best location to put templates in django project?
I understood TEMPLATE_DIRS
requires an absolute path. And I don't like absolute paths in my code.
So this is working well for me, in settings.py
:
import os
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(os.path.realpath(__file__)),
"../APPNAME/templates")
)
Placed in <PROJECT>/<APP>/templates/<APP>/template.html
for app-specific templates to help with making the app reusable elsewhere.
For general "global" templates I put them in <PROJECT>/templates/template.html
Previous solution didn't work in my case. I used:
TEMPLATE_DIRS = [ os.path.join(os.path.dirname(os.path.realpath(__file__)),"../myapp/templates") ]