如何从 django 交互式 shell 打印 TEMPLATE_DIRS 的值?
我想打印这个值以用于调试目的。我该怎么做呢?
打印 TEMPLATE_DIRS
不起作用 打印设置.TEMPLATE_DIRS
不起作用。
I would like to print this value for debugging purposes. How can I do it?
print TEMPLATE_DIRS
doesn't workprint settings.TEMPLATE_DIRS
doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您先导入设置了吗?
Did you import the settings first?
我认为最简单的,因此您可能正在寻找的答案是将以下内容添加到您的settings.py
print ("This is the template.dirs", TEMPLATES[0]['DIRS'])...python 3 .x for 2.x 省略括号
,所以答案是...访问列表中的 dict 元素的标准方法 TEMPLATES[0]['DIRS']
然后,当您运行服务器时,这些值将在非常开始
I think the easiest, and therefore the ans you may be looking for is to add the following to your settings.py
print ("This is the template.dirs", TEMPLATES[0]['DIRS'])...python 3.x for 2.x leave out the parentheses
so the answer is... standard way to access dict element within a list TEMPLATES[0]['DIRS']
Then when you run your server the values will be printed out, at the very beginning