{"id":35670302,"url":"https://github.com/wylee/django-local-settings","last_synced_at":"2026-01-05T19:01:23.013Z","repository":{"id":57420677,"uuid":"116898646","full_name":"wylee/django-local-settings","owner":"wylee","description":"An alternative way to specify settings for Django projects. Supports local and secret settings for different environments. Also supports loading settings from environment variables.","archived":false,"fork":false,"pushed_at":"2022-10-16T09:53:58.000Z","size":392,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-09-25T04:44:43.501Z","etag":null,"topics":["12-factor","config","django","dotenv","ini","json","settings"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wylee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-10T02:44:57.000Z","updated_at":"2021-11-04T06:19:31.000Z","dependencies_parsed_at":"2022-09-16T14:21:39.290Z","dependency_job_id":null,"html_url":"https://github.com/wylee/django-local-settings","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/wylee/django-local-settings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wylee%2Fdjango-local-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wylee%2Fdjango-local-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wylee%2Fdjango-local-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wylee%2Fdjango-local-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wylee","download_url":"https://codeload.github.com/wylee/django-local-settings/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wylee%2Fdjango-local-settings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28218048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["12-factor","config","django","dotenv","ini","json","settings"],"created_at":"2026-01-05T19:00:46.533Z","updated_at":"2026-01-05T19:01:23.005Z","avatar_url":"https://github.com/wylee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Local settings for Django projects\n\nThis package provides a couple different ways to handle local settings\nin Django projects:\n\n1. Using environment variables\n2. Using settings files\n\n## General Features\n\n- Supports Python 3.7 - 3.10\n- Supports Django 2.0 - 4.1\n- Local settings can be defined with validators and doc strings\n- Local settings can be nested inside lists and dicts\n- Settings can be injected into other settings using Django template\n  syntax\n\n## Using Environment Variables\n\nIn your project's Django settings module, define which settings should\nbe loaded from environment variables:\n\n    from local_settings import inject_settings, EnvSetting\n\n    SECRET_KEY = EnvSetting(\"SECRET_KEY\")\n\n    DATABASES = {\n        \"default\": {\n            \"ENGINE\": \"django.db.backends.postgresql\",\n            \"NAME\": EnvSetting(\"DATABASE_NAME\"),\n            \"USER\": EnvSetting(\"DATABASE_USER\"),\n            \"PASSWORD\": EnvSetting(\"DATABASE_PASSWORD\"),\n            \"HOST\": EnvSetting(\"DATABASE_HOST\"),\n        },\n    }\n\n    # ... other Django settings ...\n\n    inject_settings(env_only=True)\n\nThen create an *untracked* `.env` file that sets the corresponding\nenvironment variables like so:\n\n    SECRET_KEY=\"very secret key\"\n    DATABASE_NAME=\"dev_db\"\n    ...\n\nIn development, the `.env` file should be in your Django project root\nnext to `manage.py`.\n\n## Using a Settings File\n\nAnother approach to local settings is to use a settings file--an INI\nfile where the values are JSON-encoded.\n\nWhen using a settings file, some additional features are available\n\n- Local settings can be defined with defaults\n- When running interactively (e.g., when running `./manage.py\n  runserver`), missing settings will be prompted for\n- The included `make-local-settings` script can be used to generate\n  local settings files\n- A settings file can extend from a base settings file\n\nIn your project's Django settings module, define which settings should\nbe loaded from a settings file:\n\n    from local_settings import inject_settings, LocalSetting, SecretSetting\n\n    from django.core.management import utils\n\n    # This is used to demonstrate interpolation.\n    PACKAGE = \"local_settings\"\n\n    DEBUG = LocalSetting(default=False)\n\n    DATABASES = {\n        \"default\": {\n            \"ENGINE\": \"django.db.backends.postgresql\",\n            \"NAME\": LocalSetting(default=\"{{ PACKAGE }}\"),\n            \"USER\": LocalSetting(default=\"{{ PACKAGE }}\"),\n            \"PASSWORD\": SecretSetting(),\n            \"HOST\": LocalSetting(default=\"localhost\"),\n            \"PORT\": \"\",\n        },\n    }\n\n    # If a secret setting specifies a default, it must be a callable\n    # that generates the value; this discourages using the same\n    # secret in different environments.\n    SECRET_KEY = SecretSetting(\n        default=utils.get_random_secret_key,\n        doc=\"The secret key for doing secret stuff\",\n    )\n\n    # ... other Django settings ...\n\n    inject_settings()\n\nThen create an *untracked* `local.cfg` file with values for the settings\nlike so:\n\n    DEBUG = false\n    DATABASES.default.PASSWORD = \"database password\"\n\nIn development, the `local.cfg` file should be in your Django project\nroot next to `manage.py`.\n\nYou can also use the environment variable `LOCAL_SETTINGS_FILE` to\nspecify a different local settings file.\n\n## Historical note\n\nThe initial commit of this package was made on October 22, 2014, and the\nfirst release was published to [PyPI] on March 11, 2015. At the time,  I\ndidn't know about TOML. Otherwise, I probably (maybe?) would have found\na way to use TOML for Django settings.\n\n[PyPI]: https://pypi.org/project/django-local-settings/\n\nWhen I heard about TOML--I think related to `pyproject.toml` becoming\na thing--I remember thinking it was quite similar to this package (or\nvice versa), especially the splitting of dotted names into dictionaries\nand the use of \"rich\" values rather than plain text.\n\nOne of the biggest differences, besides this package being\nDjango-specific, is interpolation of both values *and* keys, which I\nfind handy (more for values, but occasionally for keys.)\n\nAnother difference is that with TOML the config file section name\nbecomes part of the dictionary structure, whereas in\n`django-local-settings` it doesn't. In that regard,\n`django-local-settings` is more geared toward environments, such as a\ndevelopment and production.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwylee%2Fdjango-local-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwylee%2Fdjango-local-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwylee%2Fdjango-local-settings/lists"}