Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

django

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 ?

like image 373
Frankie Ribery Avatar asked Jun 16 '11 09:06

Frankie Ribery


People also ask

Where are Django settings?

Default settings These defaults live in the module django/conf/global_settings.py . Here's the algorithm Django uses in compiling settings: Load settings from global_settings.py . Load settings from the specified settings file, overriding the global settings as necessary.

Which file contains the configuration of your website in Django?

Insights about settings.py file. A Django settings file contains all the configuration of your Django Project.

What is Django admin shell?

django-admin is Django's command-line utility for administrative tasks. This document outlines all it can do. In addition, manage.py is automatically created in each Django project.

What does settings py do in Django?

settings.py is a core file in Django projects. It holds all the configuration values that your web app needs to work; database settings, logging configuration, where to find static files, API keys if you work with external APIs, and a bunch of other stuff.


1 Answers

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.

like image 125
pajton Avatar answered Oct 07 '22 06:10

pajton