🧭 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.
✨ 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
--filterkeyword to narrow results (onallcommand) - 🧪 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 hasdjango_settings_inspectorinstalled and added toINSTALLED_APPS.djinspectis a lightweight CLI shipped with the package — at present it supports theallcommand. 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 byall; 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.
-
allShow 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')
-
authShow authentication-related settings (AUTH_USER_MODEL,AUTHENTICATION_BACKENDS, login/logout URLs, password hashers, session auth-related keys). Example:python manage.py auth
-
cacheShow cache configuration (CACHES,CACHE_MIDDLEWARE_*, cacheops settings if present,USE_ETAGS, etc.). Example:python manage.py cache
-
coreShow core environment and security basics (BASE_DIR,DEBUG, maskedSECRET_KEY,ALLOWED_HOSTS). Example:python manage.py core
-
dbShow database-related settings (DATABASES,DEFAULT_AUTO_FIELD). Example:python manage.py db
-
diffsettingsDisplay the difference between project settings and Django defaults (similar to Django’s built-indiffsettings, but colorized if Rich is available). Example:python manage.py diffsettings
-
emailShow email configuration (EMAIL_BACKEND,EMAIL_HOST,EMAIL_PORT,DEFAULT_FROM_EMAIL,ADMINS, etc.). Example:python manage.py email
-
installedShowINSTALLED_APPSand related app-level settings (e.g.DEFAULT_AUTO_FIELD,MIGRATION_MODULES). Example:python manage.py installed
-
localeShow internationalization and timezone settings (LANGUAGE_CODE,TIME_ZONE,USE_I18N,USE_TZ). Example:python manage.py locale
-
loggingShow logging configuration (LOGGING,LOGGING_CONFIG,DEFAULT_LOGGING, etc.). Example:python manage.py logging
-
mediaShow media/file upload settings (MEDIA_URL,MEDIA_ROOT,DEFAULT_FILE_STORAGE, and common cloud-storage vars if present). Example:python manage.py media
-
middlewareShow middleware stack plus related flags (MIDDLEWARE,MIDDLEWARE_CLASSES,SECURE_*,CSRF_*,SESSION_*, CORS settings if present). Example:python manage.py middleware
-
securityShow security & HTTPS-related settings (CSRF_COOKIE_SECURE,SESSION_COOKIE_SECURE,SECURE_SSL_REDIRECT, HSTS settings,X_FRAME_OPTIONS, etc.). Example:python manage.py security
-
sessionShow session-specific configuration (SESSION_ENGINE, cookie names, age,SESSION_SAVE_EVERY_REQUEST,SESSION_FILE_PATH, etc.). Example:python manage.py session
-
siteSite and environment-level settings (BASE_DIR,ROOT_URLCONF,WSGI_APPLICATION,ASGI_APPLICATION,ALLOWED_HOSTS,SITE_ID, etc.). Example:python manage.py site
-
staticShow static files settings (STATIC_URL,STATICFILES_DIRS,STATIC_ROOT,STATICFILES_STORAGE,STATICFILES_FINDERS, WhiteNoise options if present). Example:python manage.py static
-
storageShow storage-related settings (DEFAULT_FILE_STORAGE,STORAGES, upload limits and permissions,DATA_UPLOAD_MAX_MEMORY_SIZE, etc.). Example:python manage.py storage
-
templateShow template engine settings (TEMPLATES,TEMPLATE_DIRS,OPTIONScontext processors/loaders/jinja options). Example:python manage.py template
-
validatorShow 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
-
djinspectCLI is provided as a convenience and currently runs theallcommand: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.clito test CLI - To publish to PyPI:
🧑💻 Contributing
- Fork the repository
- Create a new branch (
git checkout -b feature/my-feature) - Commit changes (
git commit -am 'Add my feature') - Push to your branch (
git push origin feature/my-feature) - Open a Pull Request
⚖️ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT © 2025 Hadi Cahyadi
author
Metadata
Release files for django-settings-inspector 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_settings_inspector-1.0.5.tar.gz | 26.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_settings_inspector-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.3 kB
Release files / django_settings_inspector-1.0.5.tar.gz
| Download URL | django_settings_inspector-1.0.5.tar.gz |
|---|---|
| Size | 26.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21d3d14ea8745201ddfb1fd25d17e95330f92d6786d15d90493430cc33d59754
|
|
BLAKE2b-256 checksum How to use checksums |
8a08c4b346209d1da41862bd09e00ff33ac78fb9b92212b371744a914ec78cc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / django_settings_inspector-1.0.5-py3-none-any.whl
| Download URL | django_settings_inspector-1.0.5-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ad15569f7294a1199b07f5e0a8b37b926b01a6a7223ff2bdef6c46f710a5539
|
|
BLAKE2b-256 checksum How to use checksums |
c370aabbf51e42b07eb7fad82b569b2c5f202ba87dbc30a5a3dec3580d538a04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|