Reputation: 1029
Below is a part of my directory structure. I am keeping settings in a separate folder for keeping them different for produvtion and development.
DjangoApp
templates/
base.html
OtherApp/
DjangoApp/
manage.py
__init__.py
settings/
__init__.py
base.py
local.py
test.py
production.py
Below are the template settings in my base.py setting file.
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
)
It searches for the templates directory inside the settings folder. How to resolve this?
Upvotes: 1
Views: 413
Reputation: 369144
Call dirname
three times:
import os
dirname = os.path.dirname
PROJECT_PATH = dirname(dirname(dirname(os.path.abspath(__file__))))
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
)
dirname(...)
: ../DjangoApp/DjangoApp/settings
dirname(dirname(...))
: ../DjangoApp/DjangoApp
dirname(dirname(dirname(...)))
: ../DjangoApp
Upvotes: 2