Skip to main content

Dynamic Configuration for your Django project

Project description

django-bongpy

Build codecov

Django-bongpy provides dynamic configuration for your Django project which you can control from Django admin. You can change your configurations at any time without any deployment.

Note: You cannot add settings required for Django to operate in this like INSTALLED_APPS

Requirements

  • Python > 3
  • Django > 1.10

Setup

  1. Run below command to install.

pip install django-bongpy

  1. Add bongpy in your INSTALLED_APPS.
  2. Run migration by running following command

python manage.py migrate

Usage


Just go to your admin dashboard, in the Bongpy section, add configurations.

Config Type

It supports the following types of configurations. You need to set the correct type for your value otherwise value will be treated as string value and will not be processed into actual data type.

  • String
  • Number
  • Boolean
  • Json
  • Date
  • Datetime
  • Time

String

By default every value will be string.

Number

Number includes integers as well as decimal numbers.

Boolean

For boolean value, see below chart.

True False
t f
T F
y n
Y N
yes no
YES NO
true false
True False
TRUE FALSE
on off
On Off
ON OFF
1 0

Json

A valid json is required when the config type is selected as Json.

Date

Date should be in YYYY-MM-DD format. It will be converted to datetime.date object.

Datetime

Datetime should be in YYYY-MM-DD HH:MM:SS format and it will be converted to datetime object.

Time

Time should be in HH:MM:SS format and it will be converted to datetime.time object.

Usage in code

In your code, you can use it like this.

from bongpy.configs import configs

print(configs.KEY_OF_YOUR_CONFIGURATION)

At any time, when you will change your config value or add a new value, it will be available to use in you code.

Grouping

You can group configurations. Configurations of a particular group can be accessed like this.

from bongpy.configs import configs

print(configs.grouped(group='NAME_OF_GROUP'))

Default value

It is quite possible when you are using a configuration in your code and you have not added that configuration yet. In this case it is best to define a default value of that configuration in your settings so that that default value will be used instead of an error. To define default value of your configurations, define BONGPY_DEFAULTS in settings like this

BONGPY_DEFAULTS = {
    "KEY_1": True,
    "KEY_2": 2000
}

When this key will be added, that value will be used instead of this default value. These configurations will be loaded in database automatically.

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-bongpy-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

django_bongpy-1.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file django-bongpy-1.0.0.tar.gz.

File metadata

  • Download URL: django-bongpy-1.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for django-bongpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c56476ef2e03773acd84fc4b148ce8f2a7815f1eff59e2690681bae76749b3ab
MD5 4fbb4710e700f183f53b2e52cc751ecb
BLAKE2b-256 15a3090c37d22b4e8974f87d0dd10d56e687288603970e1df647a6cb6e5da127

See more details on using hashes here.

File details

Details for the file django_bongpy-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_bongpy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92e63eeef1fd0c3fc0f24a49c7f80db27cc629fcd198af5bf22758b3a481e1f8
MD5 7e7206b79dc4cadca221680b805f9676
BLAKE2b-256 c423dbb063c80de82351824ee1db56adc2363f064d16788c89a4556488747aaf

See more details on using hashes here.

Supported by

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