Django元组检查:TEMPLATE_DIRS应该是元组吗? [英] Django tuple checking: TEMPLATE_DIRS should be tuple?

查看:253
本文介绍了Django元组检查:TEMPLATE_DIRS应该是元组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试Django 1.7。

I'm trying Django 1.7.

这是我的TEMPLATE_DIRS设置:

This is my TEMPLATE_DIRS setting:

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates').replace('\\', '/')
)

这对Django 1.6来说不错,但不适用于Django 1.7。

which is fine for Django 1.6, but doesn't work for Django 1.7.

有人可以解释一下吗?
Thx !!

Can someone explains this? Thx!!

推荐答案

您需要一个尾随因为它是一个元组,见下文,最后一个

You need a trailing , for it to be a tuple, see below, the last ,

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), 'templates').replace('\\', '/'),
)

当元组中有一个元素时,您需要在末尾留下一个逗号,例如(a,)是具有单个元素 a 的元组,但(a)只需解析为 a

When there's a single element in the tuple you need to leave a trailing comma at the end, e.g. (a,) is a tuple with single element a, but (a) just resolves to whatever a is.

这篇关于Django元组检查:TEMPLATE_DIRS应该是元组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆