Skip to main content

Extended Settings for Django Project with settings.d/

Project description

django-extended-settings

Apps for Django to extend global settings with additional files

Initialize other configuration settings for django project Other configurations must be set in /path/to/project/djangoproject/settings.d/*_settings.py

    Project/
    |_ apps1/
    |_ ...
    |_ project/
       |_ settings.py
       |_ urls.py
       |_ ...
       |_ settings.d/
          |_ one_settings.py
          |_ second_settings.py

The current version of the Django Extended Settings is 1.2.0. It works on Django ≥ 2.0. (not tested other)

Installation

Getting the code

The recommended way to install the Django Extended Settings is via pip or pipenv:

$ pip install django-extended-settings

Prerequisites

Make sure add extended_settings to your INSTALLED_APPS setting:

INSTALLED_APPS = [
    # ...
    'extended_settings',
    # ...
]

Play settings into your project

Create sub directory settings.d/ into django project directory and put your configuration into independant files with this patterns *_settings.py

sample : /path/to/project/djangopython/settings.d/production_settings.py

Play database settings

You can add some settings in database

$ ./manage.py migrate

In your python files, you can create settings (in command for example) like this

from extended_settings.models import ExtentedSettings

o = ExtentedSettings()
o.name = "My home page location"
o.key = "hostname"
o.value = "http://localhost:8000"
o.save()

To retrieve settings in your views, ...

from extended_settings.models import ExtentedSettings

my_var = ExtentedSettings.get("hostname")
my_var = ExtentedSettings.get("hostname", 'default value')

my_int = ExtentedSettings.get_int("my-int")
my_float = ExtentedSettings.get_float("my-float", 100.0)
my_bool = ExtentedSettings.get_boolean("my-bool") # True = yes, y, true, 1, ...

Misc

The Django Extended Settings is released under the BSD license, like Django itself. If you like it, please consider contributing!

The Django Extended Settings was originally created by Mickael Badet in September 2018.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-extended-settings-1.3.0.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file django-extended-settings-1.3.0.tar.gz.

File metadata

  • Download URL: django-extended-settings-1.3.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.18

File hashes

Hashes for django-extended-settings-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5c198ca06562528aa41e5fb6f4b53a7fbd3c06a95f688e8526135e194158171a
MD5 561b9df0415fff48ce16a92a1dce4d2a
BLAKE2b-256 be4c7373df98c24e0d058531e88c34f34b66f0b16c942dceda160bc64534eaef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page