2015-04-12 59 views
0

眼下如何讓Django在項目根目錄中搜索模板?

如果我添加了這些設置的settings.py

INSTALLED_APPS = (
'django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'project', 
) 

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'), 
) 

它將爲index.html的搜索在

where_manage_py_is_at/project/templates/index.html 

where_manage_py_is_at/templates/index.html 

這是非常自從

os.path.join(BASE_DIR, 'templates'), 

where_manage_py_is_at/templates/index.html 

誰能告訴我爲什麼Django的這樣做呢?

感謝

回答

0

如果你想要做這樣的嘗試

manage.py #at文件的頂部像

#!/usr/bin/env python 
import os 
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 

settings.py

from manage import BASE_DIR as T_BASE_DIR 
TEMPLATE_DIRS = (
    os.path.join(T_BASE_DIR, 'templates'), 
)