[Answered ]-Django settings module and relative paths

2👍

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

Leave a comment