如何在django shell中打印我的设置内容? [英] How do I print out the contents of my settings in a django shell?

查看:62
本文介绍了如何在django shell中打印我的设置内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 python manage.py shell 时,我可以打印出python路径

When I run python manage.py shell, I can print out the python path

>>> import sys
>>> sys.path

我应该键入什么来检查所有django设置?

What should I type to introspect all my django settings ?

推荐答案

from django.conf import settings
dir(settings)

,然后从 dir(设置)显示的内容中选择属性:

and then choose attribute from what dir(settings) have shown you to say:

settings.name

其中名称是您感兴趣的属性

或者:

settings.__dict__

打印所有设置。但是它还会打印模块标准属性,这可能会使输出混乱。

prints all the settings. But it prints also the module standard attributes, which may somewhat clutter the output.

这篇关于如何在django shell中打印我的设置内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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