我的django版本是1.8.3,我在manager.py同目录下创建了templates文件夹,然后在setting中设置
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
然后在views.py中调用templates中的模板base.html,
def test(request) :
return render(request,'base.html')
url中也设置好了,访问时会显示TemplateDoesNotExist,错误信息中load的路径是如下几个
/usr/local/lib/python2.7/dist-packages/bootstrap_admin/templates/base.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/base.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/base.html (File does not exist)
这其中也没有我的template路径啊,然后我将templates文件夹放到我的app文件夹中,并把setting.py中的TEMPLATE_DIRS设置成
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'wenzhang/templates'),)
,然后view.py中什么都没改就可以访问了,我如果在view.py中访问个没有的base1.html,在debug信息中显示的是:
/usr/local/lib/python2.7/dist-packages/bootstrap_admin/templates/base1.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/base1.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/base1.html (File does not exist)
/home/tenshine/Documents/django/myblog/wenzhang/templates/base1.html (File does not exist)
最后一条就是我设置的路径了,为什么放在manager.py同目录不行,别人的工程都是放在manager.py目录下啊?
请高手看下这是为什么?