django-dynamic-configs 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_dynamic_configs-1.0.0/CHANGELOG.md +43 -0
- django_dynamic_configs-1.0.0/LICENSE +21 -0
- django_dynamic_configs-1.0.0/MANIFEST.in +7 -0
- django_dynamic_configs-1.0.0/PKG-INFO +102 -0
- django_dynamic_configs-1.0.0/README.md +66 -0
- django_dynamic_configs-1.0.0/SECURITY.md +45 -0
- django_dynamic_configs-1.0.0/pyproject.toml +107 -0
- django_dynamic_configs-1.0.0/scripts/update_currencies.py +131 -0
- django_dynamic_configs-1.0.0/setup.cfg +4 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/PKG-INFO +102 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/SOURCES.txt +124 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/dependency_links.txt +1 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/entry_points.txt +2 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/requires.txt +4 -0
- django_dynamic_configs-1.0.0/src/django_dynamic_configs.egg-info/top_level.txt +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/__init__.py +34 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/_overrides.py +101 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/admin.py +590 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/api.py +270 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/apps.py +14 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/cache.py +267 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/checks.py +76 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/conf.py +46 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/constants.py +27 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/__init__.py +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/__init__.py +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/admin.py +33 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/apps.py +15 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/checks.py +46 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/migrations/0001_initial.py +73 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/migrations/__init__.py +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/contrib/simple_history/models.py +7 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/exceptions.py +16 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/__init__.py +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/config.py +247 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/datetime.py +194 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/fields.py +151 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/json.py +46 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/list.py +416 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/forms/money.py +131 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/log.py +48 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/migrations/0001_initial.py +51 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/migrations/__init__.py +0 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/models.py +49 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/py.typed +0 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/signals.py +36 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/static/dynamic_configs/admin.css +236 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/static/dynamic_configs/admin.js +283 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/static/dynamic_configs/json_editor.js +587 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/static/dynamic_configs/list_editor.js +499 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/static/dynamic_configs/suggestions.js +216 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/test/__init__.py +303 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/test/pytest_plugin.py +39 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/__init__.py +1 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/base.py +170 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/builtin.py +136 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/iso4217.py +168 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/money.py +183 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/registry.py +300 -0
- django_dynamic_configs-1.0.0/src/dynamic_configs/types/serializers.py +484 -0
- django_dynamic_configs-1.0.0/tests/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/broken_type_module.py +3 -0
- django_dynamic_configs-1.0.0/tests/browser/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/browser/admin.py +23 -0
- django_dynamic_configs-1.0.0/tests/browser/conftest.py +89 -0
- django_dynamic_configs-1.0.0/tests/browser/models.py +20 -0
- django_dynamic_configs-1.0.0/tests/browser/test_config_admin.py +53 -0
- django_dynamic_configs-1.0.0/tests/browser/test_currency_dropdown.py +390 -0
- django_dynamic_configs-1.0.0/tests/browser/test_json_editor.py +470 -0
- django_dynamic_configs-1.0.0/tests/browser/test_list_editor.py +535 -0
- django_dynamic_configs-1.0.0/tests/browser/test_list_editor_raw.py +222 -0
- django_dynamic_configs-1.0.0/tests/browser/test_money_currency.py +107 -0
- django_dynamic_configs-1.0.0/tests/browser/test_money_steps.py +81 -0
- django_dynamic_configs-1.0.0/tests/browser/test_whole_numbers.py +90 -0
- django_dynamic_configs-1.0.0/tests/browser/test_zones.py +112 -0
- django_dynamic_configs-1.0.0/tests/conftest.py +40 -0
- django_dynamic_configs-1.0.0/tests/contrib/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/test_admin.py +97 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/test_checks.py +33 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/test_models.py +23 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/test_revert.py +174 -0
- django_dynamic_configs-1.0.0/tests/contrib/simple_history/urls.py +46 -0
- django_dynamic_configs-1.0.0/tests/cross_process_reader.py +24 -0
- django_dynamic_configs-1.0.0/tests/custom_types.py +140 -0
- django_dynamic_configs-1.0.0/tests/failing_cache.py +17 -0
- django_dynamic_configs-1.0.0/tests/forms/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/forms/test_config.py +346 -0
- django_dynamic_configs-1.0.0/tests/forms/test_datetime.py +214 -0
- django_dynamic_configs-1.0.0/tests/forms/test_fields.py +175 -0
- django_dynamic_configs-1.0.0/tests/forms/test_list.py +431 -0
- django_dynamic_configs-1.0.0/tests/forms/test_money.py +290 -0
- django_dynamic_configs-1.0.0/tests/real_cache.py +124 -0
- django_dynamic_configs-1.0.0/tests/scripts/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/scripts/test_update_currencies.py +167 -0
- django_dynamic_configs-1.0.0/tests/settings.py +75 -0
- django_dynamic_configs-1.0.0/tests/test/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/test/test_override_configs.py +510 -0
- django_dynamic_configs-1.0.0/tests/test/test_pytest_plugin.py +69 -0
- django_dynamic_configs-1.0.0/tests/test_admin.py +851 -0
- django_dynamic_configs-1.0.0/tests/test_admin_list_editor.py +268 -0
- django_dynamic_configs-1.0.0/tests/test_api.py +629 -0
- django_dynamic_configs-1.0.0/tests/test_api_async.py +35 -0
- django_dynamic_configs-1.0.0/tests/test_cache.py +186 -0
- django_dynamic_configs-1.0.0/tests/test_checks.py +128 -0
- django_dynamic_configs-1.0.0/tests/test_conf.py +23 -0
- django_dynamic_configs-1.0.0/tests/test_exceptions.py +11 -0
- django_dynamic_configs-1.0.0/tests/test_init.py +54 -0
- django_dynamic_configs-1.0.0/tests/test_log.py +56 -0
- django_dynamic_configs-1.0.0/tests/test_models.py +35 -0
- django_dynamic_configs-1.0.0/tests/test_money.py +151 -0
- django_dynamic_configs-1.0.0/tests/test_overrides.py +79 -0
- django_dynamic_configs-1.0.0/tests/test_readme.py +30 -0
- django_dynamic_configs-1.0.0/tests/test_real_cache.py +287 -0
- django_dynamic_configs-1.0.0/tests/test_settings.py +38 -0
- django_dynamic_configs-1.0.0/tests/test_signals.py +170 -0
- django_dynamic_configs-1.0.0/tests/types/__init__.py +0 -0
- django_dynamic_configs-1.0.0/tests/types/test_base.py +254 -0
- django_dynamic_configs-1.0.0/tests/types/test_builtin.py +112 -0
- django_dynamic_configs-1.0.0/tests/types/test_iso4217.py +31 -0
- django_dynamic_configs-1.0.0/tests/types/test_money.py +244 -0
- django_dynamic_configs-1.0.0/tests/types/test_registry.py +304 -0
- django_dynamic_configs-1.0.0/tests/types/test_round_trip.py +242 -0
- django_dynamic_configs-1.0.0/tests/types/test_serializers.py +523 -0
- django_dynamic_configs-1.0.0/tests/urls.py +4 -0
- django_dynamic_configs-1.0.0/tox.ini +206 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
6
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-11-18
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Typed runtime settings stored in the database (`dynamic_configs.models.Config`): each has a unique name, a type, a
|
|
13
|
+
value and an optional description, and admins can add, edit and delete them.
|
|
14
|
+
- The API: `get`, `get_or_create`, `update` and `delete`, with async variants `aget`, `aget_or_create`, `aupdate` and
|
|
15
|
+
`adelete`, and the exceptions `ConfigError`, `ConfigDoesNotExist`, `ConfigTypeError` and `ConfigValueError`. A
|
|
16
|
+
`get` given a default never raises.
|
|
17
|
+
- Built-in types: `str`, `text`, `int`, `float`, `decimal`, `bool`, `date`, `datetime` (following Django's time zone
|
|
18
|
+
settings), `json` (an object or array, nested at most 128 levels deep), and the durations `seconds`, `minutes`,
|
|
19
|
+
`hours`, `days` and `weeks`.
|
|
20
|
+
- List and set variants of every type except `json` (`list:<key>`, `set:<key>`).
|
|
21
|
+
- Custom types declared in `DYNAMIC_CONFIGS["TYPES"]`: a class, a serializer, and optionally a form field, help text,
|
|
22
|
+
raw-mode help text, a sort key or compare function, and `options` (keyword arguments for the serializer). Nothing an
|
|
23
|
+
admin enters is ever imported, evaluated or executed.
|
|
24
|
+
- Cached reads through any Django cache, one entry per setting, refreshed when a save or delete commits; a missing
|
|
25
|
+
setting is cached too.
|
|
26
|
+
- System checks for the `DYNAMIC_CONFIGS` setting (`dynamic_configs.E001` to `E005`) and the admin
|
|
27
|
+
(`dynamic_configs.W001` and `E006`).
|
|
28
|
+
- The admin, built on stock admin pages so admin skins apply: a two-step add page, each type's own form field, a JSON
|
|
29
|
+
editor (formatting, a validity note, colours and a whitespace view), a list editor (an item editor, a raw mode for
|
|
30
|
+
pasting, and sorting), whole-number inputs that trim a typed decimal to its whole part, and number inputs whose
|
|
31
|
+
arrows count from multiples of their step.
|
|
32
|
+
- Test helpers that need neither the database nor the cache: `dynamic_configs.test.override_configs`, and a pytest
|
|
33
|
+
plugin with the `config_overrides` fixture.
|
|
34
|
+
- Example custom types, not registered by default: `money` (an amount with at most 2 decimal places) and
|
|
35
|
+
`money_currency` (an amount and a currency code). An amount with more than 2 places is refused,
|
|
36
|
+
unless the type's `options` set a `rounding`.
|
|
37
|
+
- Currency suggestions for `money_currency`: its currency input offers the ISO 4217 codes (from SIX Group, with their
|
|
38
|
+
names) as you type, or the codes and labels of a `currencies` option; the suggestions never restrict what is entered.
|
|
39
|
+
In the admin the currency input opens a dropdown listing `USD - US Dollar` and filters as you type.
|
|
40
|
+
A monthly workflow checks the list and opens a pull request when it changes.
|
|
41
|
+
- An optional django-simple-history integration (`dynamic_configs.contrib.simple_history`, installed with the
|
|
42
|
+
`simple-history` extra) that records every change and adds the History button to the admin, with the system checks
|
|
43
|
+
`dynamic_configs.E101` and `E102`. Restoring a past version never changes a config's type.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tecktron
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# The sdist carries the whole test suite, so the package can be tested where it's built from the sdist, plus the
|
|
2
|
+
# changelog, the security policy and the tox configuration. The wheel holds only the package (see [tool.setuptools] in
|
|
3
|
+
# pyproject.toml).
|
|
4
|
+
include CHANGELOG.md SECURITY.md tox.ini
|
|
5
|
+
graft tests
|
|
6
|
+
global-exclude __pycache__ *.py[cod]
|
|
7
|
+
include scripts/update_currencies.py
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-dynamic-configs
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Typed runtime settings for Django that admins can add and edit, read through a small cached API.
|
|
5
|
+
Author: Tecktron
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Tecktron/django-dynamic-configs
|
|
8
|
+
Project-URL: Documentation, https://django-dynamic-configs.readthedocs.io/
|
|
9
|
+
Project-URL: Source, https://github.com/Tecktron/django-dynamic-configs
|
|
10
|
+
Project-URL: Issues, https://github.com/Tecktron/django-dynamic-configs/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Tecktron/django-dynamic-configs/blob/main/CHANGELOG.md
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Web Environment
|
|
14
|
+
Classifier: Framework :: Django
|
|
15
|
+
Classifier: Framework :: Django :: 5.2
|
|
16
|
+
Classifier: Framework :: Django :: 6.0
|
|
17
|
+
Classifier: Framework :: Django :: 6.1
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: Django>=5.2
|
|
33
|
+
Provides-Extra: simple-history
|
|
34
|
+
Requires-Dist: django-simple-history>=3.8; extra == "simple-history"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# django-dynamic-configs
|
|
38
|
+
|
|
39
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
40
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
41
|
+
[](https://django-dynamic-configs.readthedocs.io/)
|
|
42
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
43
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
44
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
45
|
+
[](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE)
|
|
46
|
+
|
|
47
|
+
Typed runtime settings for Django that admins can add and edit in the Django admin, read from code through a small,
|
|
48
|
+
cached API.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install django-dynamic-configs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Add it to `INSTALLED_APPS`, then create its table:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
INSTALLED_APPS = [
|
|
60
|
+
# ...
|
|
61
|
+
"django.contrib.admin",
|
|
62
|
+
"dynamic_configs",
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
python manage.py migrate
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To record every change with django-simple-history, install the extra:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
pip install "django-dynamic-configs[simple-history]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import dynamic_configs
|
|
80
|
+
|
|
81
|
+
# Create the setting the first time; later calls return what is stored.
|
|
82
|
+
page_size, created = dynamic_configs.get_or_create("PAGE_SIZE", "int", 20, description="Items per list page.")
|
|
83
|
+
|
|
84
|
+
page_size = dynamic_configs.get("PAGE_SIZE", 20) # a cached read, with a default
|
|
85
|
+
dynamic_configs.update("PAGE_SIZE", 50) # change it from code
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Admins can then change `PAGE_SIZE` under **Configs** in the Django admin, and the code above reads their value.
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
The full documentation is at https://django-dynamic-configs.readthedocs.io/.
|
|
93
|
+
|
|
94
|
+
## Security
|
|
95
|
+
|
|
96
|
+
Please report a vulnerability privately, as the
|
|
97
|
+
[security policy](https://github.com/Tecktron/django-dynamic-configs/blob/main/SECURITY.md) describes, not in a public
|
|
98
|
+
issue.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT. See [LICENSE](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE).
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# django-dynamic-configs
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
5
|
+
[](https://django-dynamic-configs.readthedocs.io/)
|
|
6
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
7
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
8
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
9
|
+
[](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE)
|
|
10
|
+
|
|
11
|
+
Typed runtime settings for Django that admins can add and edit in the Django admin, read from code through a small,
|
|
12
|
+
cached API.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
pip install django-dynamic-configs
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Add it to `INSTALLED_APPS`, then create its table:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
INSTALLED_APPS = [
|
|
24
|
+
# ...
|
|
25
|
+
"django.contrib.admin",
|
|
26
|
+
"dynamic_configs",
|
|
27
|
+
]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
python manage.py migrate
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
To record every change with django-simple-history, install the extra:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
pip install "django-dynamic-configs[simple-history]"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import dynamic_configs
|
|
44
|
+
|
|
45
|
+
# Create the setting the first time; later calls return what is stored.
|
|
46
|
+
page_size, created = dynamic_configs.get_or_create("PAGE_SIZE", "int", 20, description="Items per list page.")
|
|
47
|
+
|
|
48
|
+
page_size = dynamic_configs.get("PAGE_SIZE", 20) # a cached read, with a default
|
|
49
|
+
dynamic_configs.update("PAGE_SIZE", 50) # change it from code
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Admins can then change `PAGE_SIZE` under **Configs** in the Django admin, and the code above reads their value.
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
The full documentation is at https://django-dynamic-configs.readthedocs.io/.
|
|
57
|
+
|
|
58
|
+
## Security
|
|
59
|
+
|
|
60
|
+
Please report a vulnerability privately, as the
|
|
61
|
+
[security policy](https://github.com/Tecktron/django-dynamic-configs/blob/main/SECURITY.md) describes, not in a public
|
|
62
|
+
issue.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT. See [LICENSE](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Security fixes are released for the latest version only. If you can, check that the issue is still there in the
|
|
6
|
+
latest release before reporting it.
|
|
7
|
+
|
|
8
|
+
## Reporting a vulnerability
|
|
9
|
+
|
|
10
|
+
Please don't report a vulnerability in a public issue, discussion or pull request.
|
|
11
|
+
|
|
12
|
+
Report it privately through GitHub instead: open the repository's
|
|
13
|
+
[Security tab](https://github.com/Tecktron/django-dynamic-configs/security) and choose **Report a vulnerability**.
|
|
14
|
+
|
|
15
|
+
Keep the report short:
|
|
16
|
+
|
|
17
|
+
- what the issue is, and what an attacker could do with it
|
|
18
|
+
- how to reproduce it, ideally with a small proof of concept
|
|
19
|
+
- the versions involved: django-dynamic-configs, Django and Python, and any optional extra or cache backend
|
|
20
|
+
- a fix, if you have one
|
|
21
|
+
|
|
22
|
+
If you used AI tools to find the issue or write the report, say so, and check every claim yourself before sending it.
|
|
23
|
+
|
|
24
|
+
## What happens next
|
|
25
|
+
|
|
26
|
+
- You'll get a reply within 14 days. The reply acknowledges the report; it isn't a date for the fix.
|
|
27
|
+
- If the issue is confirmed, the fix is prepared in a private GitHub security advisory, where you can follow it and
|
|
28
|
+
help.
|
|
29
|
+
- The fixed version is released, then the advisory is published, with a CVE when one is warranted. You're credited
|
|
30
|
+
unless you'd rather not be.
|
|
31
|
+
- If it isn't a vulnerability, the reply says why.
|
|
32
|
+
|
|
33
|
+
Please keep the issue private until the fix is released, or for 90 days after your report, whichever comes first.
|
|
34
|
+
|
|
35
|
+
## Scope
|
|
36
|
+
|
|
37
|
+
This policy covers the code in this repository and the package published from it. Django and the other packages this
|
|
38
|
+
one works with have their own security policies; report their issues to them (Django's is at
|
|
39
|
+
https://www.djangoproject.com/security/).
|
|
40
|
+
|
|
41
|
+
These work as designed, so they aren't vulnerabilities:
|
|
42
|
+
|
|
43
|
+
- The `DYNAMIC_CONFIGS` setting, custom types included, is code the project trusts, like the rest of its settings.
|
|
44
|
+
- Anyone with change permission on configs in the admin can change their values; the project's permissions decide who
|
|
45
|
+
has it.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "django-dynamic-configs"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Typed runtime settings for Django that admins can add and edit, read through a small cached API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Tecktron" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
dependencies = ["Django>=5.2"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Environment :: Web Environment",
|
|
18
|
+
"Framework :: Django",
|
|
19
|
+
"Framework :: Django :: 5.2",
|
|
20
|
+
"Framework :: Django :: 6.0",
|
|
21
|
+
"Framework :: Django :: 6.1",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Programming Language :: Python :: 3.14",
|
|
31
|
+
"Programming Language :: Python :: 3.15",
|
|
32
|
+
"Typing :: Typed",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
simple-history = ["django-simple-history>=3.8"]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/Tecktron/django-dynamic-configs"
|
|
40
|
+
Documentation = "https://django-dynamic-configs.readthedocs.io/"
|
|
41
|
+
Source = "https://github.com/Tecktron/django-dynamic-configs"
|
|
42
|
+
Issues = "https://github.com/Tecktron/django-dynamic-configs/issues"
|
|
43
|
+
Changelog = "https://github.com/Tecktron/django-dynamic-configs/blob/main/CHANGELOG.md"
|
|
44
|
+
|
|
45
|
+
[project.entry-points.pytest11]
|
|
46
|
+
dynamic_configs = "dynamic_configs.test.pytest_plugin"
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.packages.find]
|
|
49
|
+
where = ["src"]
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.package-data]
|
|
52
|
+
dynamic_configs = ["py.typed", "static/dynamic_configs/*.js", "static/dynamic_configs/*.css"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
addopts = ["--ds=tests.settings", "--strict-markers", "-p", "pytester"]
|
|
56
|
+
filterwarnings = [
|
|
57
|
+
# From pytest-base-url, which pytest-playwright installs, not from this project.
|
|
58
|
+
"ignore:Session-scoped fixtures defined as instance methods are deprecated",
|
|
59
|
+
]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
pythonpath = ["."]
|
|
62
|
+
|
|
63
|
+
[tool.coverage.run]
|
|
64
|
+
branch = true
|
|
65
|
+
source_pkgs = ["dynamic_configs"]
|
|
66
|
+
omit = ["*/migrations/*"]
|
|
67
|
+
|
|
68
|
+
[tool.coverage.paths]
|
|
69
|
+
source = ["src/dynamic_configs", "*/site-packages/dynamic_configs"]
|
|
70
|
+
|
|
71
|
+
[tool.coverage.report]
|
|
72
|
+
fail_under = 100
|
|
73
|
+
show_missing = true
|
|
74
|
+
skip_covered = true
|
|
75
|
+
exclude_also = ["if TYPE_CHECKING:"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
line-length = 120
|
|
79
|
+
target-version = "py310"
|
|
80
|
+
src = ["src", "."]
|
|
81
|
+
# Markdown is excluded: ruff also formats code blocks in .md files, and the docs' examples are aligned for reading.
|
|
82
|
+
extend-exclude = ["venv", ".tox", "docs/_build", "*.md"]
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint]
|
|
85
|
+
# E/F: pycodestyle and pyflakes; UP: pyupgrade; B: bugbear; S: bandit (security); C4: comprehensions;
|
|
86
|
+
# N: pep8-naming; DJ: Django; PT: pytest style; I: isort; PTH: pathlib; D: pydocstyle (docstrings required)
|
|
87
|
+
select = ["E", "F", "UP", "B", "S", "C4", "N", "DJ", "PT", "I", "PTH", "D"]
|
|
88
|
+
# E501: the formatter handles line length.
|
|
89
|
+
# DJ001: Config.value is deliberately a nullable TextField: NULL is empty (None), distinct from "".
|
|
90
|
+
ignore = ["E501", "DJ001"]
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint.pydocstyle]
|
|
93
|
+
convention = "pep257"
|
|
94
|
+
|
|
95
|
+
[tool.ruff.lint.isort]
|
|
96
|
+
force-wrap-aliases = true
|
|
97
|
+
split-on-trailing-comma = true
|
|
98
|
+
known-first-party = ["dynamic_configs", "tests"]
|
|
99
|
+
|
|
100
|
+
[tool.ruff.lint.per-file-ignores]
|
|
101
|
+
# Tests use plain asserts, dummy secrets and pytest.raises without match; they don't need docstrings.
|
|
102
|
+
"tests/**" = ["S101", "S105", "S106", "PT011", "D"]
|
|
103
|
+
"src/dynamic_configs/**/migrations/**" = ["D"]
|
|
104
|
+
|
|
105
|
+
[tool.ruff.format]
|
|
106
|
+
quote-style = "double"
|
|
107
|
+
indent-style = "space"
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Regenerate ``src/dynamic_configs/types/iso4217.py`` from SIX Group's ISO 4217 List One.
|
|
2
|
+
|
|
3
|
+
Run by hand, or monthly from the GitHub workflow, which opens a pull request when the list changed::
|
|
4
|
+
|
|
5
|
+
python scripts/update_currencies.py [--from FILE] [--out PATH] [--summary PATH]
|
|
6
|
+
|
|
7
|
+
The module is rewritten only when the suggested currencies (codes or names) differ from the current ones, not when
|
|
8
|
+
only the publication date does.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import ast
|
|
15
|
+
import json
|
|
16
|
+
import re
|
|
17
|
+
import xml.etree.ElementTree as ET
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from urllib.request import urlopen
|
|
20
|
+
|
|
21
|
+
SOURCE = "https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def parse(xml: bytes, minimum: int = 100) -> tuple[str, dict[str, str]]:
|
|
25
|
+
"""Return the publication date and the suggested currencies (code to ISO name, sorted by code).
|
|
26
|
+
|
|
27
|
+
Entries with no code (Antarctica and the like), funds (``IsFund="true"``) and the ``ZZ`` entries (metals, bond
|
|
28
|
+
units, testing, no currency) are left out. Raises ``ValueError`` on anything that is not List One, or that holds
|
|
29
|
+
fewer than ``minimum`` currencies (a partial download).
|
|
30
|
+
"""
|
|
31
|
+
try:
|
|
32
|
+
root = ET.fromstring(xml) # noqa: S314 (SIX over HTTPS, a reviewed PR follows, expat refuses entity attacks)
|
|
33
|
+
except ET.ParseError as error:
|
|
34
|
+
raise ValueError(f"Not well-formed XML: {error}") from error
|
|
35
|
+
if root.tag != "ISO_4217":
|
|
36
|
+
raise ValueError(f"Not an ISO 4217 list: the root element is {root.tag!r}")
|
|
37
|
+
published = root.get("Pblshd")
|
|
38
|
+
if not published:
|
|
39
|
+
raise ValueError("The list has no publication date (Pblshd)")
|
|
40
|
+
|
|
41
|
+
currencies: dict[str, str] = {}
|
|
42
|
+
for item in root.iter("CcyNtry"):
|
|
43
|
+
code = (item.findtext("Ccy") or "").strip()
|
|
44
|
+
name_element = item.find("CcyNm")
|
|
45
|
+
is_fund = name_element is not None and name_element.get("IsFund") == "true"
|
|
46
|
+
if not code or is_fund or (item.findtext("CtryNm") or "").strip().startswith("ZZ"):
|
|
47
|
+
continue
|
|
48
|
+
if not re.fullmatch(r"[A-Z]{3}", code):
|
|
49
|
+
raise ValueError(f"Not a currency code: {code!r}")
|
|
50
|
+
name = (item.findtext("CcyNm") or "").strip()
|
|
51
|
+
if not name:
|
|
52
|
+
raise ValueError(f"No name for {code}")
|
|
53
|
+
if currencies.setdefault(code, name) != name:
|
|
54
|
+
raise ValueError(f"{code} has two names: {currencies[code]!r} and {name!r}")
|
|
55
|
+
if len(currencies) < minimum:
|
|
56
|
+
raise ValueError(f"Only {len(currencies)} currencies, expected at least {minimum}: a partial download?")
|
|
57
|
+
return published, dict(sorted(currencies.items()))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def render(published: str, currencies: dict[str, str]) -> str:
|
|
61
|
+
"""Return the source of the data module, formatted as ruff format would."""
|
|
62
|
+
lines = [
|
|
63
|
+
'"""The ISO 4217 currencies suggested for ``money_currency``, as ISO publishes their names.',
|
|
64
|
+
"",
|
|
65
|
+
"Generated by ``scripts/update_currencies.py`` from SIX Group's ISO 4217 List One; don't edit it by hand.",
|
|
66
|
+
"Funds, metals, bond units, testing and no-currency entries are left out.",
|
|
67
|
+
'"""',
|
|
68
|
+
"",
|
|
69
|
+
f"PUBLISHED = {json.dumps(published)}",
|
|
70
|
+
f"SOURCE = {json.dumps(SOURCE)}",
|
|
71
|
+
"CURRENCIES = {",
|
|
72
|
+
*(f" {json.dumps(code)}: {json.dumps(name, ensure_ascii=False)}," for code, name in currencies.items()),
|
|
73
|
+
"}",
|
|
74
|
+
]
|
|
75
|
+
return "\n".join(lines) + "\n"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def main(argv: list[str] | None = None) -> int:
|
|
79
|
+
"""Fetch (or read) List One and rewrite the module when the suggested currencies changed."""
|
|
80
|
+
|
|
81
|
+
def current(path: Path) -> dict[str, str]:
|
|
82
|
+
"""Return the ``CURRENCIES`` of the module at ``path`` without importing it, or ``{}`` if it is missing."""
|
|
83
|
+
if not path.exists():
|
|
84
|
+
return {}
|
|
85
|
+
for node in ast.parse(path.read_text(encoding="utf-8")).body:
|
|
86
|
+
if isinstance(node, ast.Assign) and [target.id for target in node.targets] == ["CURRENCIES"]:
|
|
87
|
+
return ast.literal_eval(node.value)
|
|
88
|
+
raise ValueError(f"{path} has no CURRENCIES")
|
|
89
|
+
|
|
90
|
+
def summarize(old: dict[str, str], new: dict[str, str]) -> str:
|
|
91
|
+
"""Describe how ``new`` differs from ``old``, or ``unchanged``."""
|
|
92
|
+
added = [f"{code} ({new[code]})" for code in new if code not in old]
|
|
93
|
+
removed = [f"{code} ({old[code]})" for code in old if code not in new]
|
|
94
|
+
renamed = [f"{code} ({old[code]} -> {new[code]})" for code in new if code in old and old[code] != new[code]]
|
|
95
|
+
lines = [
|
|
96
|
+
f"{label}: {', '.join(items)}"
|
|
97
|
+
for label, items in (("added", added), ("removed", removed), ("renamed", renamed))
|
|
98
|
+
if items
|
|
99
|
+
]
|
|
100
|
+
return "\n".join(lines) or "unchanged"
|
|
101
|
+
|
|
102
|
+
parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
|
103
|
+
parser.add_argument("--from", dest="source", type=Path, help="read this List One file instead of fetching SOURCE")
|
|
104
|
+
parser.add_argument(
|
|
105
|
+
"--out",
|
|
106
|
+
type=Path,
|
|
107
|
+
default=Path(__file__).resolve().parent.parent / "src" / "dynamic_configs" / "types" / "iso4217.py",
|
|
108
|
+
help="the module to write (default: the package's)",
|
|
109
|
+
)
|
|
110
|
+
parser.add_argument("--summary", type=Path, help="also write the summary to this file")
|
|
111
|
+
arguments = parser.parse_args(argv)
|
|
112
|
+
|
|
113
|
+
if arguments.source:
|
|
114
|
+
xml = arguments.source.read_bytes()
|
|
115
|
+
else:
|
|
116
|
+
with urlopen(SOURCE, timeout=60) as response: # noqa: S310 (a constant https URL)
|
|
117
|
+
xml = response.read()
|
|
118
|
+
published, currencies = parse(xml)
|
|
119
|
+
|
|
120
|
+
old = current(arguments.out)
|
|
121
|
+
summary = summarize(old, currencies)
|
|
122
|
+
if currencies != old:
|
|
123
|
+
arguments.out.write_text(render(published, currencies), encoding="utf-8")
|
|
124
|
+
print(summary)
|
|
125
|
+
if arguments.summary:
|
|
126
|
+
arguments.summary.write_text(summary + "\n", encoding="utf-8")
|
|
127
|
+
return 0
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if __name__ == "__main__":
|
|
131
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-dynamic-configs
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Typed runtime settings for Django that admins can add and edit, read through a small cached API.
|
|
5
|
+
Author: Tecktron
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Tecktron/django-dynamic-configs
|
|
8
|
+
Project-URL: Documentation, https://django-dynamic-configs.readthedocs.io/
|
|
9
|
+
Project-URL: Source, https://github.com/Tecktron/django-dynamic-configs
|
|
10
|
+
Project-URL: Issues, https://github.com/Tecktron/django-dynamic-configs/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Tecktron/django-dynamic-configs/blob/main/CHANGELOG.md
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Web Environment
|
|
14
|
+
Classifier: Framework :: Django
|
|
15
|
+
Classifier: Framework :: Django :: 5.2
|
|
16
|
+
Classifier: Framework :: Django :: 6.0
|
|
17
|
+
Classifier: Framework :: Django :: 6.1
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: Django>=5.2
|
|
33
|
+
Provides-Extra: simple-history
|
|
34
|
+
Requires-Dist: django-simple-history>=3.8; extra == "simple-history"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# django-dynamic-configs
|
|
38
|
+
|
|
39
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
40
|
+
[](https://github.com/Tecktron/django-dynamic-configs/actions/workflows/ci.yml)
|
|
41
|
+
[](https://django-dynamic-configs.readthedocs.io/)
|
|
42
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
43
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
44
|
+
[](https://pypi.org/project/django-dynamic-configs/)
|
|
45
|
+
[](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE)
|
|
46
|
+
|
|
47
|
+
Typed runtime settings for Django that admins can add and edit in the Django admin, read from code through a small,
|
|
48
|
+
cached API.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install django-dynamic-configs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Add it to `INSTALLED_APPS`, then create its table:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
INSTALLED_APPS = [
|
|
60
|
+
# ...
|
|
61
|
+
"django.contrib.admin",
|
|
62
|
+
"dynamic_configs",
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
python manage.py migrate
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To record every change with django-simple-history, install the extra:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
pip install "django-dynamic-configs[simple-history]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import dynamic_configs
|
|
80
|
+
|
|
81
|
+
# Create the setting the first time; later calls return what is stored.
|
|
82
|
+
page_size, created = dynamic_configs.get_or_create("PAGE_SIZE", "int", 20, description="Items per list page.")
|
|
83
|
+
|
|
84
|
+
page_size = dynamic_configs.get("PAGE_SIZE", 20) # a cached read, with a default
|
|
85
|
+
dynamic_configs.update("PAGE_SIZE", 50) # change it from code
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Admins can then change `PAGE_SIZE` under **Configs** in the Django admin, and the code above reads their value.
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
The full documentation is at https://django-dynamic-configs.readthedocs.io/.
|
|
93
|
+
|
|
94
|
+
## Security
|
|
95
|
+
|
|
96
|
+
Please report a vulnerability privately, as the
|
|
97
|
+
[security policy](https://github.com/Tecktron/django-dynamic-configs/blob/main/SECURITY.md) describes, not in a public
|
|
98
|
+
issue.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT. See [LICENSE](https://github.com/Tecktron/django-dynamic-configs/blob/main/LICENSE).
|