How do I print out the contents of my settings in a django shell?

后端 未结 5 1046
不思量自难忘°
不思量自难忘° 2021-01-30 12:41

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

>>> import sys
>>> sys.path

What should I typ

5条回答
  •  半阙折子戏
    2021-01-30 13:36

    from django.conf import settings
    dir(settings)
    

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

    settings.name
    

    where name is the attribute that is of your interest

    Alternatively:

    settings.__dict__
    

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

提交回复
热议问题