Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2216810
  • 博文数量: 287
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2130
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-31 14:30
个人简介

自己慢慢积累。

文章分类

全部博文(287)

分类: Web开发

2016-09-08 17:03:56

最近在学习django
学习的是1.1.0版本的教程,到配置templates 这步卡壳了
查询后才知道1.6版本后此项设置有改动。

我用的1.10.1 版本。
settings.py 设置如下:

点击(此处)折叠或打开

  1. TEMPLATES = [
  2.     {
  3.         'BACKEND': 'django.template.backends.django.DjangoTemplates',
  4.         'DIRS': [os.path.join(BASE_DIR, 'templates')],
  5.         'APP_DIRS': True,
  6.         'OPTIONS': {
  7.             'context_processors': [
  8.                 'django.template.context_processors.debug',
  9.                 'django.template.context_processors.request',
  10.                 'django.contrib.auth.context_processors.auth',
  11.                 'django.contrib.messages.context_processors.messages',
  12.             ],
  13.         },
  14.     },
  15. ]
DIRS 就是要设templates路径的
这里解释下这个BASE_DIR 这个在settings.py的最前面有设置,其实就是当前settings.py文件所在目录的上一级目录
.join 是粘贴两个字符串的
所以这样设置的DIRS 其实就是: settings.py 文件所在目录的上一级目录/templates






阅读(1518) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~