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.
โจ 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_settings_inspector-1.0.5.tar.gz.
File metadata
- Download URL: django_settings_inspector-1.0.5.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21d3d14ea8745201ddfb1fd25d17e95330f92d6786d15d90493430cc33d59754
|
|
| MD5 |
08d461bf4015ccf10360483e5c21f23d
|
|
| BLAKE2b-256 |
8a08c4b346209d1da41862bd09e00ff33ac78fb9b92212b371744a914ec78cc8
|
File details
Details for the file django_settings_inspector-1.0.5-py3-none-any.whl.
File metadata
- Download URL: django_settings_inspector-1.0.5-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ad15569f7294a1199b07f5e0a8b37b926b01a6a7223ff2bdef6c46f710a5539
|
|
| MD5 |
4c94571b58681f8d53e671b8b8a0a88a
|
|
| BLAKE2b-256 |
c370aabbf51e42b07eb7fad82b569b2c5f202ba87dbc30a5a3dec3580d538a04
|