Settings Model
Documentation: https://django-settings-model.readthedocs.io
Source: https://github.com/gregschmit/django-settings-model
PyPI: https://pypi.org/project/django-settings-model/
This Django reusable app implements a base SettingsModel class to allow settings to be edited and saved in the database. For any particular project, you probably want to customize which settings are exposed, so while there is a Settings example implementation that you can use, the abstract model SettingsModel can be used to construct your own settings model(s), and things like webserver restarts are handled in the abstract model class.
The Problem: Sometimes you want to build an app that can be managed by non-developers, and things like timezone, hostname, or SMTP settings may need to be editable from the UI.
The Solution: This app implements a base SettingsModel class that allows you to expose settings to a user interface via the database. It writes these stub settings to separate files which you try/include at the end of your main settings file. This way you have sensible defaults, but when the user created/edits a model file in the UI, those settings override. There is a mechanism to touch the wsgi.py/manage.py files when saving, so the only thing left to do is either configure your web server to watch those files and reboot when they are touched, or use a tool like incrond to watch those files and trigger your webserver to reboot when they are touched.
How to Use
$ pip install django-settings-model
You can use the builtin Settings model by including this app (settings_model) in your INSTALLED_APPS and running migrations, or you can create your own custom settings model, inheriting from settings_model.base.SettingsModel. If you want to build a custom settings Model, use the Settings model as a reference implementation.
For the included Settings model, you need to add the following to the end of your settings.py file:
try:
from .model_settings import *
except:
pass
If you create a custom Settings model, then ensure you set the __settings_filename__ appropriately (avoid conflicts with other settings models), and ensure you call its .init() class method in the application’s AppConfig.ready() method. This will update the settings with the true values (and optionally create an initial settings model instance) on startup.
Settings
SETTINGS_MODEL_REBOOT_FILES (default []): This is a list of files that should be touched when the settings model is saved to signal to the webserver to reboot. If it is falsy, then the system will try to find and touch the file BASE_DIR/manage.py and the wsgi.py file defined by WSGI_APPLICATION.
Contributing
Submit a pull request if you would like to contribute. You must only contribute code that you have authored or otherwise hold the copyright to, and you must make any contributions to this project available under the MIT license.
Metadata
Release files for django-settings-model 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-settings-model-0.6.0.tar.gz | 9.0 kB | Without provenance | Details for django-settings-model-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_settings_model-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for django_settings_model-0.6.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / django-settings-model-0.6.0.tar.gz
| Download URL | django-settings-model-0.6.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34a7a58527bbb21421e381ddf174ee4df2b848aeb06af4e8f1acbdce7efb58aa
|
|
BLAKE2b-256 checksum How to use checksums |
be867f1f07ddc8fdd4f10ed82ef084ade7fa09ea598a7c475a0580417be89db2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / django_settings_model-0.6.0-py3-none-any.whl
| Download URL | django_settings_model-0.6.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
adbd966172a6d604d69fb2a8b362fe47f800be2b237b93f89536e52837a441b9
|
|
BLAKE2b-256 checksum How to use checksums |
62a8a1e34060539162ffbc741f1eed5b6997ef8340805bf710bece765127010a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for django-settings-model 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.