Skip to main content

A Django management and CLI tool to inspect and colorize project settings

Project description

๐Ÿงญ Django Settings Inspector

Django Settings Inspector is a developer tool that extends Djangoโ€™s built-in management commands to inspect and visualize project configuration in a structured and colorized format.

It helps you quickly understand, debug, and document your Django settings โ€” whether you are auditing security, reviewing deployments, or checking environment consistency.

PyPI version Python Versions License Downloads


โœจ Features

  • ๐Ÿ” Inspect all Django configuration categories
  • ๐ŸŽจ Beautiful color output using Rich
  • ๐Ÿงฉ Works as standard Django management commands
  • ๐Ÿงฐ Includes standalone CLI (djinspect) for quick inspection
  • โš™๏ธ Optional --filter keyword to narrow results (on all command)
  • ๐Ÿงช Fully testable with pytest
  • ๐Ÿ’ก No side effects โ€” purely read-only and safe

๐Ÿ“ฆ Installation

From PyPI:

pip install django-settings-inspector

From source (for development):

git clone https://github.com/cumulus13/django-settings-inspector.git
cd django-settings-inspector
pip install -e .

โš™๏ธ Setup

Add django_settings_inspector to your Django projectโ€™s INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "django_settings_inspector",
]

Thatโ€™s it! You can now run any of the new management commands:

python manage.py all

Or use the standalone CLI:

djinspect all

โš™๏ธ Usage

1๏ธโƒฃ Import in your Django project

Instead of a giant settings.py, you can modularize it:

# settings.py
from django_settings_inspector.management.commands.core import *
from django_settings_inspector.management.commands.db import *
from django_settings_inspector.management.commands.cache import *
from django_settings_inspector.management.commands.logging import *
from django_settings_inspector.management.commands.security import *

Or load all in one line:

from django_settings_inspector.management.commands.all import *

2๏ธโƒฃ Use the CLI inspector

List all detected settings:

django-settings-inspector all

Filter by keyword:

django-settings-inspector all --filter DATABASE

Example Output:

DATABASES:
  default:
    ENGINE: django.db.backends.sqlite3
    NAME: db.sqlite3

CACHES:
  default:
    BACKEND: django.core.cache.backends.locmem.LocMemCache

3๏ธโƒฃ Django management command

You can run it as a Django command too:

python manage.py all

With filters:

python manage.py all --filter TIME_ZONE

๐Ÿง  Example Workflow

Hereโ€™s how you might use it in a real-world Django project:

# Create new Django project
django-admin startproject myproject

# Optionally import Django Settings Inspector for exploration
cd myproject
echo "from django_settings_inspector.management.commands.all import *" >> settings.py

# Keep your existing settings below (do not remove SECRET_KEY or BASE_DIR)

# Run server
python manage.py runserver

And youโ€™ll instantly have access to all modularized settings and their management commands.


๐ŸŽจ Example Output

When rich is installed:

python manage.py static

Produces:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Setting            โ”ƒ Value                                                       โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ STATIC_URL         โ”‚ /static/                                                    โ”‚
โ”‚ STATIC_ROOT        โ”‚ BASE_DIR / "staticfiles"                                    โ”‚
โ”‚ STATICFILES_DIRS   โ”‚ ['assets', 'frontend/static']                               โ”‚
โ”‚ STATICFILES_STORAGEโ”‚ 'django.contrib.staticfiles.storage.StaticFilesStorage'     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿงฐ CLI Options

Command Description
all Show all grouped settings; supports --filter <keyword>
auth Authentication-related settings
cache Caching configuration
core Core environment & global options (BASE_DIR, DEBUG, SECRET_KEY, etc.)
db Database configuration
diffsettings Colorized diff between Django defaults and current settings
email Email backend and related configs
installed Installed apps and related settings
locale Language and timezone settings
logging Logging configuration
media Media and upload file settings
middleware Middleware stack
security Security and HTTPS-related settings
session Session configuration
site Site and root application settings
static Static files settings
storage File storage and upload settings
template Template engine settings
validator Validation & password policy settings

๐Ÿงฉ Available Commands (run with django-admin)

Command Description
djinspect/manage all Show all settings (merged view)
djinspect/manage core Show core Django settings
djinspect/manage db Show database-related settings
djinspect/manage auth Show authentication settings
djinspect/manage cache Show cache settings
djinspect/manage logging Show logging configuration
djinspect/manage security Show security settings
djinspect/manage email Show email settings
djinspect/manage session Show session settings
djinspect/manage site Show site-related settings
djinspect/manage static Show static file configuration
djinspect/manage storage Show media and file storage settings
djinspect/manage template Show template settings
djinspect/manage locale Show i18n/l10n and timezone settings
djinspect/manage installed List installed apps
djinspect/manage middleware List middleware components
djinspect/manage validator Validate settings consistency

๐Ÿงฐ CLI & Management Commands

This package exposes a set of Django management commands (usable with python manage.py <command>) and a small standalone CLI (djinspect) that currently wraps the all command.

Note: python manage.py <command> works inside any Django project that has django_settings_inspector installed and added to INSTALLED_APPS. djinspect is a lightweight CLI shipped with the package โ€” at present it supports the all command. If you want it to proxy all commands, tell me and Iโ€™ll add it.

Global options

  • -h, --help โ€” show help for a command.
  • --filter <keyword> (or -f <keyword>) โ€” only supported by all; case-insensitive keyword filter for the aggregated output.

All commands (management commands included in the package)

Use python manage.py <command> (examples below). All commands print human-readable configuration; if rich is installed they will print a colored table/syntax-highlighted block.

  • all Show grouped settings for many categories (Database, Cache, Static, Media, Auth, Security, Email, etc.). Example:

    python manage.py all
    python manage.py all --filter cache      # only sections/keys matching "cache"
    djinspect all --filter email            # CLI wrapper for 'all' (djinspect supports 'all')
    
  • auth Show authentication-related settings (AUTH_USER_MODEL, AUTHENTICATION_BACKENDS, login/logout URLs, password hashers, session auth-related keys). Example:

    python manage.py auth
    
  • cache Show cache configuration (CACHES, CACHE_MIDDLEWARE_*, cacheops settings if present, USE_ETAGS, etc.). Example:

    python manage.py cache
    
  • core Show core environment and security basics (BASE_DIR, DEBUG, masked SECRET_KEY, ALLOWED_HOSTS). Example:

    python manage.py core
    
  • db Show database-related settings (DATABASES, DEFAULT_AUTO_FIELD). Example:

    python manage.py db
    
  • diffsettings Display the difference between project settings and Django defaults (similar to Djangoโ€™s built-in diffsettings, but colorized if Rich is available). Example:

    python manage.py diffsettings
    
  • email Show email configuration (EMAIL_BACKEND, EMAIL_HOST, EMAIL_PORT, DEFAULT_FROM_EMAIL, ADMINS, etc.). Example:

    python manage.py email
    
  • installed Show INSTALLED_APPS and related app-level settings (e.g. DEFAULT_AUTO_FIELD, MIGRATION_MODULES). Example:

    python manage.py installed
    
  • locale Show internationalization and timezone settings (LANGUAGE_CODE, TIME_ZONE, USE_I18N, USE_TZ). Example:

    python manage.py locale
    
  • logging Show logging configuration (LOGGING, LOGGING_CONFIG, DEFAULT_LOGGING, etc.). Example:

    python manage.py logging
    
  • media Show media/file upload settings (MEDIA_URL, MEDIA_ROOT, DEFAULT_FILE_STORAGE, and common cloud-storage vars if present). Example:

    python manage.py media
    
  • middleware Show middleware stack plus related flags (MIDDLEWARE, MIDDLEWARE_CLASSES, SECURE_*, CSRF_*, SESSION_*, CORS settings if present). Example:

    python manage.py middleware
    
  • security Show security & HTTPS-related settings (CSRF_COOKIE_SECURE, SESSION_COOKIE_SECURE, SECURE_SSL_REDIRECT, HSTS settings, X_FRAME_OPTIONS, etc.). Example:

    python manage.py security
    
  • session Show session-specific configuration (SESSION_ENGINE, cookie names, age, SESSION_SAVE_EVERY_REQUEST, SESSION_FILE_PATH, etc.). Example:

    python manage.py session
    
  • site Site and environment-level settings (BASE_DIR, ROOT_URLCONF, WSGI_APPLICATION, ASGI_APPLICATION, ALLOWED_HOSTS, SITE_ID, etc.). Example:

    python manage.py site
    
  • static Show static files settings (STATIC_URL, STATICFILES_DIRS, STATIC_ROOT, STATICFILES_STORAGE, STATICFILES_FINDERS, WhiteNoise options if present). Example:

    python manage.py static
    
  • storage Show storage-related settings (DEFAULT_FILE_STORAGE, STORAGES, upload limits and permissions, DATA_UPLOAD_MAX_MEMORY_SIZE, etc.). Example:

    python manage.py storage
    
  • template Show template engine settings (TEMPLATES, TEMPLATE_DIRS, OPTIONS context processors/loaders/jinja options). Example:

    python manage.py template
    
  • validator Show validation and password-related settings (AUTH_PASSWORD_VALIDATORS, PASSWORD_HASHERS, PASSWORD_RESET_TIMEOUT, etc.) and related auth redirect urls. Example:

    python manage.py validator
    

Example: colorized output (when rich installed)

python manage.py static
# prints a colored table with STATIC_URL, STATIC_ROOT, STATICFILES_DIRS, etc.

Notes & Tips

  • djinspect CLI is provided as a convenience and currently runs the all command:

    djinspect all --filter cache
    

๐Ÿงช Tests (pytest)

tests/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ conftest.py
โ”œโ”€โ”€ test_core_commands.py
โ””โ”€โ”€ test_cli.py

Example test_cli.py

import subprocess
import sys

def test_cli_all_command():
    result = subprocess.run(
        [sys.executable, "-m", "django_settings_inspector.cli", "--filter", "DATABASE"],
        capture_output=True,
        text=True
    )
    assert "DATABASES" in result.stdout

def test_import_all():
    import django_settings_inspector.management.commands.all as allmod
    assert hasattr(allmod, "BASE_DIR")

Example test file: tests/test_core_commands.py

import pytest
from django.core.management import call_command

@pytest.mark.django_db
def test_all_command_runs_safely(settings):
    """Ensure 'all' command runs without error."""
    call_command("all")

def test_specific_command_outputs(settings, capsys):
    """Check output contains key variables."""
    call_command("core")
    captured = capsys.readouterr()
    assert "BASE_DIR" in captured.out

Run tests:

pytest -v

๐Ÿ’ก Tips for Development

  • Use pip install -e . during development
  • Use python -m django_settings_inspector.cli to test CLI
  • To publish to PyPI:

๐Ÿง‘โ€๐Ÿ’ป Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/my-feature)
  3. Commit changes (git commit -am 'Add my feature')
  4. Push to your branch (git push origin feature/my-feature)
  5. Open a Pull Request

โš–๏ธ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT ยฉ 2025 Hadi Cahyadi

author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_settings_inspector-1.0.5.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_settings_inspector-1.0.5-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file django_settings_inspector-1.0.5.tar.gz.

File metadata

File hashes

Hashes for django_settings_inspector-1.0.5.tar.gz
Algorithm Hash digest
SHA256 21d3d14ea8745201ddfb1fd25d17e95330f92d6786d15d90493430cc33d59754
MD5 08d461bf4015ccf10360483e5c21f23d
BLAKE2b-256 8a08c4b346209d1da41862bd09e00ff33ac78fb9b92212b371744a914ec78cc8

See more details on using hashes here.

File details

Details for the file django_settings_inspector-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_settings_inspector-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9ad15569f7294a1199b07f5e0a8b37b926b01a6a7223ff2bdef6c46f710a5539
MD5 4c94571b58681f8d53e671b8b8a0a88a
BLAKE2b-256 c370aabbf51e42b07eb7fad82b569b2c5f202ba87dbc30a5a3dec3580d538a04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page