69

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

>>> import sys
>>> sys.path

What should I type to introspect all my django settings ?

1
  • do you mean your settings.py file? Jun 16, 2011 at 9:32

5 Answers 5

86

I know that this is an old question, but with current versions of django (1.6+), you can accomplish this from the command line the following way:

python manage.py diffsettings --all

The result will show all of the settings including the defautls (denoted by ### in front of the settings name).

3
82
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.

3
  • 9
    import settings will not work. try from django.conf import settings as vinod suggested.
    – Bobo
    Sep 17, 2012 at 21:12
  • 2
    settings is a module, not a class. So settings.__dict__ is not really useful.
    – Danosaure
    Jan 17, 2014 at 15:57
  • How do you do from the settings.py file itself? I guess importing settings from settings wouldn't end well. Mar 4, 2019 at 15:05
20

In case a newbie stumbles upon this question wanting to be spoon fed the way to print out the values for all settings:

def show_settings():
    from django.conf import settings
    for name in dir(settings):
        print(name, getattr(settings, name))
15

To show all django settings (including default settings not specified in your local settings file):

from django.conf import settings
dir(settings)
3

In your shell, you can call Django's built-in diffsettings:

from django.core.management.commands import diffsettings

output = diffsettings.Command().handle(default=None, output="hash", all=False)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.