Package: django-extra-settings
django-extra-settingsconfig and manage typed extra settings using just the django admin.InstallationRunpip install django-extra-settingsAddextra_settingstosettings.INSTALLED_APPSRunpython manage.py migrateRunpython manage.py collectstaticRestart your application serverJust go to the admin where you cancreate,updateanddeleteyour settings.UsageSettingsAll these settings are optional, if not defined insettings.pythe default values (listed below) will be used.# the name of the installed app for registering the extra settings admin.EXTRA_SETTINGS_ADMIN_APP="extra_settings"# the name of the cache to use, if not found the "default" cache will be used.EXTRA_SETTINGS_CACHE_NAME="extra_settings"# a list of settings that will be available by default, each item must contain "name", "type" and "value".# check the #types section to see all the supported settings types.EXTRA_SETTINGS_DEFAULTS=[{"name":"SETTING_NAME","type":"string","value":"Hello World",},# ...]# if True, settings names will be forced to honor the standard django settings formatEXTRA_SETTINGS_ENFORCE_UPPERCASE_SETTINGS=True# if True, the template tag will fallback to django.conf.settings,# very useful to retrieve conf settings such as DEBUG.EXTRA_SETTINGS_FALLBACK_TO_CONF_SETTINGS=True# the upload_to path value of settings of type 'file'EXTRA_SETTINGS_FILE_UPLOAD_TO="files"# the upload_to path value of settings of type 'image'EXTRA_SETTINGS_IMAGE_UPLOAD_TO="images"# if True, settings name prefix list filter will be shown in the admin changelistEXTRA_SETTINGS_SHOW_NAME_PREFIX_LIST_FILTER=False# if True, settings type list filter will be shown in the admin changelistEXTRA_SETTINGS_SHOW_TYPE_LIST_FILTER=False# the package name displayed in the adminEXTRA_SETTINGS_VERBOSE_NAME="Settings"AdminYou can display the settings model admin in another installed app group by using theEXTRA_SETTINGS_ADMIN_APPsetting.You can also have a more advanced control, by registering the settings admin with multiple installed apps and filtering each app settings using thequeryset_processorargument.:warning: If you do either of the above, you must run migrations for each app that will displayextra_settingsmodel admin in its admin(because django creates migrations even for proxy models).Admin advanced configuration exampleIn your custom appphotos.adminmodule:fromextra_settings.adminimportregister_extra_settings_adminregister_extra_settings_admin(app=__name__,queryset_processor=lambdaqs:qs.filter(name__istartswith="PHOTOS_"),unregister_default=True,)In your custom appvideos.adminmodule:fromextra_settings.adminimportregister_extra_settings_adminregister_extra_settings_admin(app=__name__,queryset_processor=lambdaqs:qs.filter(name__istartswith="VIDEOS_"),unregister_default=True,)By default the"extra_settings"app has its own admin app group.CachingYou can customise the app caching options usingsettings.CACHES["extra_settings"]setting, otherwise the"default"cache will be used:CACHES={# ..."extra_settings":{"BACKEND":"django.core.cache.backends.locmem.LocMemCache","TIMEOUT":60,},# ...}By default the"extra_settings"cache is used, if you want to use another cache you can set it using theEXTRA_SETTINGS_CACHE_NAMEsetting.PythonYou cancreate,read,updateanddeletesettings programmatically:TypesThis is the list of the currently supported setting types you may need to use:Setting.TYPE_BOOLSetting.TYPE_DATESetting.TYPE_DATETIMESetting.TYPE_DECIMALSetting.TYPE_DURATIONSetting.TYPE_EMAILSetting.TYPE_FILESetting.TYPE_FLOATSetting.TYPE_IMAGESetting.TYPE_INTSetting.TYPE_JSONSetting.TYPE_STRINGSetting.TYPE_TEXTSetting.TYPE_TIMESetting.TYPE_URLCreatefromextra_settings.modelsimportSettingsetting_obj=Setting(name="SETTING_NAME",value_type=Setting.TYPE_STRING,value="django-extra-settings",)setting_obj.save()Readfromextra_settings.modelsimportSettingvalue=Setting.get("SETTING_NAME",default="django-extra-settings")Updatefromextra_settings.modelsimportSettingsetting_obj=Setting(name="SETTING_NAME",value_type=Setting.TYPE_BOOL,value=True,)setting_obj.value=Falsesetting_obj.save()Deletefromextra_settings.modelsimportSettingSetting.objects.filter(name="SETTING_NAME").delete()ValidatorsYou can define a custom validator for each setting:Validators must be defined using full python path, eg.myapp.mymodule.my_validator.Validators are called passing a single argument (the value of the setting) and if the value is valid, they should returnTrue, otherwise returningFalseorNoneaValidationErroris raised.TemplatesYou can retrieve settings in templates:{% load extra_settings %}

{% get_setting 'SETTING_NAME' default='django-extra-settings' %}TestsYou can override specific settings during tests usingextra_settings.test.override_settings.It can be used both as decorator and as context-manager:fromextra_settings.testimportoverride_settings# decorator@override_settings(SETTING_NAME_1="value for testing 1",SETTING_NAME_2="value for testing 2")deftest_with_custom_settings(self):pass# context managerdeftest_with_custom_settings(self):withoverride_settings(SETTING_NAME_1="value for testing 1",SETTING_NAME_2="value for testing 2"):passTesting# clone repositorygitclonehttps://github.com/fabiocaccamo/django-extra-settings.git&&cddjango-extra-settings# create virtualenv and activate itpython-mvenvvenv&&.venv/bin/activate# upgrade pippython-mpipinstall--upgradepip# install requirementspipinstall-rrequirements.txt-rrequirements-test.txt# install pre-commit to run formatters and linterspre-commitinstall--install-hooks# run teststox# orpythonruntests.py# orpython-mdjangotest--settings"tests.settings"LicenseReleased underMIT License.Supporting:star: Star this project onGitHub:octocat: Follow me onGitHub:blue_heart: Follow me onTwitter:moneybag: Sponsor me onGithubSee alsodjango-admin-interface- the default admin interface made customizable by the admin itself. popup windows replaced by modals. 🧙 ⚡django-colorfield- simple color field for models with a nice color-picker in the admin. 🎨django-maintenance-mode- shows a 503 error page when maintenance-mode is on. 🚧 🛠️django-redirects- redirects with full control. ↪️django-treenode- probably the best abstract model / admin for your tree based stuff. 🌳python-benedict- dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘python-codicefiscale- encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. 🇮🇹 💳python-fontbro- friendly font operations. 🧢python-fsutil- file-system utilities for lazy devs. 🧟‍♂️