TEMPLATES_FOLDER_NAME = 'jlpt1/templates'
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
print abspath(__file__)
print dirname(abspath(__file__))
print normpath(join(DJANGO_ROOT, TEMPLATES_FOLDER_NAME))
结果:
E:\PythonWorkSpace\lfctestdjango\lfctestdjango\settings.py
E:\PythonWorkSpace\lfctestdjango\lfctestdjango
E:\PythonWorkSpace\lfctestdjango
E:\PythonWorkSpace\lfctestdjango\jlpt1\templates
可使用dirname回到上一级目录。