# django-bongpy
[![Build](https://github.com/mhsiddiqui/django-bongpy/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mhsiddiqui/django-bongpy/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/mhsiddiqui/django-bongpy/branch/main/graph/badge.svg?token=FFXY6AZEDQ)](https://codecov.io/gh/mhsiddiqui/django-bongpy)
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
2. Add `bongpy` in your INSTALLED_APPS.
3. 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.
```python
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.
```python
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
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/mhsiddiqui/django-bongpy",
"name": "django-bongpy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": "",
"keywords": "django,dynamic-configuration,dynamic-settings,django-settings-from-admin",
"author": "Muhammad Hassan Siddiqui",
"author_email": "mhassan.eeng@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/15/a3/090c37d22b4e8974f87d0dd10d56e687288603970e1df647a6cb6e5da127/django-bongpy-1.0.0.tar.gz",
"platform": "any",
"description": "# django-bongpy\n\n[![Build](https://github.com/mhsiddiqui/django-bongpy/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mhsiddiqui/django-bongpy/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/mhsiddiqui/django-bongpy/branch/main/graph/badge.svg?token=FFXY6AZEDQ)](https://codecov.io/gh/mhsiddiqui/django-bongpy)\n\n\n\nDjango-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.\n\n**Note**: You cannot add settings required for Django to operate in this like *INSTALLED_APPS*\n\n# Requirements\n* Python > 3\n* Django > 1.10\n\n# Setup\n\n1. Run below command to install.\n\n> pip install django-bongpy\n\n2. Add `bongpy` in your INSTALLED_APPS.\n3. Run migration by running following command\n\n> python manage.py migrate\n\n# Usage\n_____\nJust go to your admin dashboard, in the Bongpy section, add configurations.\n\n## Config Type\n\nIt 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.\n* String\n* Number\n* Boolean\n* Json\n* Date\n* Datetime\n* Time\n\n### String\n\nBy default every value will be string. \n\n### Number\n\nNumber includes integers as well as decimal numbers. \n\n### Boolean\n\nFor boolean value, see below chart.\n\n| True | False |\n|:----:|:-----:|\n| t | f |\n| T | F |\n| y | n |\n| Y | N |\n| yes | no |\n| YES | NO |\n| true | false |\n| True | False |\n| TRUE | FALSE |\n| on | off |\n| On | Off |\n| ON | OFF |\n| 1 | 0 |\n\n### Json\nA valid json is required when the config type is selected as Json.\n\n### Date\nDate should be in `YYYY-MM-DD` format. It will be converted to `datetime.date` object.\n\n### Datetime\nDatetime should be in `YYYY-MM-DD HH:MM:SS` format and it will be converted to `datetime` object.\n\n### Time\nTime should be in `HH:MM:SS` format and it will be converted to `datetime.time` object.\n\n## Usage in code\nIn your code, you can use it like this.\n\n```python\nfrom bongpy.configs import configs\n\nprint(configs.KEY_OF_YOUR_CONFIGURATION)\n```\n\nAt any time, when you will change your config value or add a new value, it will be available to use in you code.\n\n## Grouping\n\nYou can group configurations. Configurations of a particular group can be accessed like this.\n\n```python\nfrom bongpy.configs import configs\n\nprint(configs.grouped(group='NAME_OF_GROUP'))\n```\n\n## Default value\n\nIt 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\n\n```python\nBONGPY_DEFAULTS = {\n \"KEY_1\": True,\n \"KEY_2\": 2000\n}\n```\nWhen this key will be added, that value will be used instead of this default value. These configurations will be loaded in database automatically.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Dynamic Configuration for your Django project",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/mhsiddiqui/django-bongpy"
},
"split_keywords": [
"django",
"dynamic-configuration",
"dynamic-settings",
"django-settings-from-admin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c423dbb063c80de82351824ee1db56adc2363f064d16788c89a4556488747aaf",
"md5": "7e7206b79dc4cadca221680b805f9676",
"sha256": "92e63eeef1fd0c3fc0f24a49c7f80db27cc629fcd198af5bf22758b3a481e1f8"
},
"downloads": -1,
"filename": "django_bongpy-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7e7206b79dc4cadca221680b805f9676",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 9072,
"upload_time": "2023-08-13T13:15:17",
"upload_time_iso_8601": "2023-08-13T13:15:17.384987Z",
"url": "https://files.pythonhosted.org/packages/c4/23/dbb063c80de82351824ee1db56adc2363f064d16788c89a4556488747aaf/django_bongpy-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "15a3090c37d22b4e8974f87d0dd10d56e687288603970e1df647a6cb6e5da127",
"md5": "4fbb4710e700f183f53b2e52cc751ecb",
"sha256": "c56476ef2e03773acd84fc4b148ce8f2a7815f1eff59e2690681bae76749b3ab"
},
"downloads": -1,
"filename": "django-bongpy-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "4fbb4710e700f183f53b2e52cc751ecb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 11250,
"upload_time": "2023-08-13T13:15:19",
"upload_time_iso_8601": "2023-08-13T13:15:19.309726Z",
"url": "https://files.pythonhosted.org/packages/15/a3/090c37d22b4e8974f87d0dd10d56e687288603970e1df647a6cb6e5da127/django-bongpy-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-13 13:15:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mhsiddiqui",
"github_project": "django-bongpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "django-bongpy"
}