simonw / djp

A plugin system for Django
https://djp.readthedocs.io
Apache License 2.0
85 stars 2 forks source link

Tooling to help understand what changes have been made to settings by DJP #15

Open simonw opened 1 month ago

simonw commented 1 month ago

This could be a command such as ./manage.py show_settings_diff (or similar) - it could work by having the djp.settings(globals()) function grab a snapshot of the current state before, then make the changes and stash a representation of that diff elsewhere.

simonw commented 1 month ago

Tried this just now:

>>> import json
>>> from django.conf import settings
>>> print(json.dumps(settings.__dict__, indent=2, default=repr))
{
  "_wrapped": "<Settings \"helloworld.settings\">",
  "INSTALLED_APPS": [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "djp"
  ],
  "DEBUG": true,
  "LOGGING_CONFIG": "logging.config.dictConfig",
  "LOGGING": {},
  "DEFAULT_EXCEPTION_REPORTER": "django.views.debug.ExceptionReporter",
  "FORCE_SCRIPT_NAME": null,
  "DEFAULT_TABLESPACE": "",
  "DEFAULT_AUTO_FIELD": "django.db.models.BigAutoField",
  "ABSOLUTE_URL_OVERRIDES": {},
  "AUTH_USER_MODEL": "auth.User",
  "DATABASES": {
    "default": {
      "ENGINE": "django.db.backends.sqlite3",
      "NAME": "PosixPath('/private/tmp/helloworld/db.sqlite3')",
      "ATOMIC_REQUESTS": false,
      "AUTOCOMMIT": true,
      "CONN_MAX_AGE": 0,
      "CONN_HEALTH_CHECKS": false,
      "OPTIONS": {},
      "TIME_ZONE": null,
      "USER": "",
      "PASSWORD": "",
      "HOST": "",
      "PORT": "",
      "TEST": {
        "CHARSET": null,
        "COLLATION": null,
        "MIGRATE": true,
        "MIRROR": null,
        "NAME": null
      }
    }
  },
  "USE_I18N": true,
  "LANGUAGE_CODE": "en-us",
  "LOCALE_PATHS": [],
  "DEFAULT_INDEX_TABLESPACE": ""
}

But showing the differences would be much more interesting.