django-easysettings
Easy app-specific settings for Django apps.
Provides a method for using a declarative class for an app’s default settings. The instance of this class can be used to access all project settings in place of django.conf.settings.
Installation
To install, run: pip install django-easysettings
Usage
Create a conf.py file within your app’s directory, adding attributes for the default values of your app-specific settings. They will be overridden by any project setting that is provided.
For example:
from easysettings.app import AppSettings
class Settings(AppSettings):
MYAPP_FRUIT = 'Apple'
settings = Settings()
Then in your app, rather than from django.conf import settings, use from myapp.conf import settings. For example:
from myapp.conf import settings
def dashboard(request):
context = {}
context['fruit'] = settings.MYAPP_FRUIT
if settings.DEBUG:
context['debug_mode'] = True
# ...
Dictionaries
A common pattern is to use a dictionary as a namespace for all an app’s settings, such as settings.MYAPP['settings'].
Easy-settings handles this fine, overriding any keys provided in the project while still having access to the default app settings keys.
You can also use a subclass of an AppSettings class to set up a dictionary.
from easysettings.apps import AppSettings
class MyAppSettings(AppSettings):
"""
MyApp settings
"""
#: Preferred fruit
FRUIT = 'Apple'
#: Preferred drink
DRINK = 'Water'
class Settings(AppSettings):
MYAPP = MyAppSettings
settings = Settings()
Legacy Usage
If previously your app used a common prefix (like MYAPP_) you can still support projects that still use these stand-alone legacy settings while moving to a MYAPP dictionary for your settings.
from easysettings.legacy import LegacyAppSettings
class Settings(LegacyAppSettings):
MYAPP = {'FRUIT': 'Apple'}
settings = Settings()
If a project uses settings like MYAPP_FRUIT = 'Banana' they will continue to work. As soon as a project switches to MYAPP, any MYAPP_* settings will be ignored.
While the legacy app settings class is used, the dictionary settings can still be accessed via the prefixed setting (for example, settings.MYAPP_FRUIT).
Change Log
2.0.1 (10 August 2019)
Add Python 3.7 and Django 2.2 to the test matrix.
2.0 (24 April 2018)
Full rework of project! Import is now from easysettings.app import AppSettings (but left importable from easysettings for better backwards compatibility).
Removed isolated settings functionality, unnecessary with a separate settings module for tests and/or use of the TestCase.settings() context manager.
Added easysettings.legacy.LegacyAppSettings for providing backwards compatibility for prefixed project settings when moving settings to a dictionary rather than individual settings with the same prefix.
1.1 (4 April 2017)
Django 1.11 compatibility.
1.0.1 (24 May 2012)
Included extra source files.
1.0 (16 April 2012)
Initial release.
Metadata
Release files for django-easysettings 2.0.1
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-easysettings-2.0.1.tar.gz | 6.3 kB | Without provenance | Details for django-easysettings-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_easysettings-2.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_easysettings-2.0.1-py2.py3-none-any.whl |
Total release size: 13.1 kB
Release files / django-easysettings-2.0.1.tar.gz
| Download URL | django-easysettings-2.0.1.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d472d6b64c4f9f91432da943bcc30d5dd1f2c62b2f5b457310bfa4929b08fca
|
|
BLAKE2b-256 checksum How to use checksums |
a35fd9d2666ee3f38eb9e512b993cf07c04ece703fef8a0228f2136fe7251e71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
|
Release files / django_easysettings-2.0.1-py2.py3-none-any.whl
| Download URL | django_easysettings-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
59bbbd2d369a98ee9b265180cfa4f5ec1c5af557cb7984d21b05e86f915d0d2c
|
|
BLAKE2b-256 checksum How to use checksums |
c47ccb00b51a22b940b3c60c9b59b14bef98da3c0b8bd7a40973683769f966c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
|
Security for django-easysettings 2.0.1
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.