Since os.path.dirname
gets the directory name for a specified file (in your case __file__
, you can see what this means int here) you will get the parent directory of that file.
Now os.path.abspath
gets the absolute path of the current working directory with the file name.
And last os.path.join
works by joining two paths. For example, if you have are located in /opt/python/current/app/src/myproject/
and you want to join the templates
folder to that path you do os.path.join(/opt/python/current/app/src/myproject/
,templates
)
so to get what you need you to do to get what you need
'DIRS' : [os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))),
'templates')
],
os.path.abspath
gets the absolute normalized path of __file__
then it gets the parent directory with first os.path.dirname
(innermost) and the second gets that resultant path parent directory and so on.
If by using two os.path.dirname
you get /opt/python/current/app/src/myproject/templates
that means you need one more os.path.dirname
to achieve what you want.