django-dynaconf


Namedjango-dynaconf JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/mhsiddiqui/django-dynaconf
SummaryDynamic Configuration for your Django project
upload_time2023-08-11 19:58:54
maintainer
docs_urlNone
authorMuhammad Hassan Siddiqui
requires_python>=3
licenseMIT
keywords django dynamic-configuration dynamic-settings django-settings-from-admin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-dynaconf

[![Build](https://github.com/mhsiddiqui/django-dynaconf/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mhsiddiqui/django-dynaconf/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/mhsiddiqui/django-dynaconf/branch/main/graph/badge.svg?token=FFXY6AZEDQ)](https://codecov.io/gh/mhsiddiqui/django-dynaconf)



Django-dynaconf 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-dynaconf

2. Add `django_dynaconf` in your INSTALLED_APPS.
3. Run migration by running following command

> python manage.py migrate

# Usage
_____
Just go to your admin dashboard, in the Dynaconf section, add configurations. 

## Listing
![image info](./images/listing.png)

## Form
![image info](./images/form.png)

## 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 django_dynaconf.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 django_dynaconf.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 `DYNACONF_DEFAULTS` in settings like this

```python
DYNACONF_DEFAULTS = {
    "KEY_1": True,
    "KEY_2": 2000
}
```
When this key will be added, that value will be used instead of this default value.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mhsiddiqui/django-dynaconf",
    "name": "django-dynaconf",
    "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/86/b7/db45cbe92aec6eb2a469dadc6b8220fe70678063d640063e1f74bac9c316/django-dynaconf-1.3.1.tar.gz",
    "platform": "any",
    "description": "# django-dynaconf\n\n[![Build](https://github.com/mhsiddiqui/django-dynaconf/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mhsiddiqui/django-dynaconf/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/mhsiddiqui/django-dynaconf/branch/main/graph/badge.svg?token=FFXY6AZEDQ)](https://codecov.io/gh/mhsiddiqui/django-dynaconf)\n\n\n\nDjango-dynaconf 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-dynaconf\n\n2. Add `django_dynaconf` 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 Dynaconf section, add configurations. \n\n## Listing\n![image info](./images/listing.png)\n\n## Form\n![image info](./images/form.png)\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 django_dynaconf.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 django_dynaconf.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 `DYNACONF_DEFAULTS` in settings like this\n\n```python\nDYNACONF_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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Dynamic Configuration for your Django project",
    "version": "1.3.1",
    "project_urls": {
        "Homepage": "https://github.com/mhsiddiqui/django-dynaconf"
    },
    "split_keywords": [
        "django",
        "dynamic-configuration",
        "dynamic-settings",
        "django-settings-from-admin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca52aa03c3a4d08f60518fd215fc2783192b78320a8d93a7eaaa04d55d501b19",
                "md5": "6eaff77fc29c65eb663141be730c2177",
                "sha256": "a493e91b9a50349fd2899e915f2971bd41f23776d78c3a4b609cccb4f09bc352"
            },
            "downloads": -1,
            "filename": "django_dynaconf-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6eaff77fc29c65eb663141be730c2177",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 8911,
            "upload_time": "2023-08-11T19:58:52",
            "upload_time_iso_8601": "2023-08-11T19:58:52.204531Z",
            "url": "https://files.pythonhosted.org/packages/ca/52/aa03c3a4d08f60518fd215fc2783192b78320a8d93a7eaaa04d55d501b19/django_dynaconf-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86b7db45cbe92aec6eb2a469dadc6b8220fe70678063d640063e1f74bac9c316",
                "md5": "fbc21b9aa873a90a1990216c855c54d9",
                "sha256": "69e832da6f3b9a620def7cc371b4f7fcf1d0a432c157b27244bf0e87ea7db663"
            },
            "downloads": -1,
            "filename": "django-dynaconf-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fbc21b9aa873a90a1990216c855c54d9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 10827,
            "upload_time": "2023-08-11T19:58:54",
            "upload_time_iso_8601": "2023-08-11T19:58:54.317760Z",
            "url": "https://files.pythonhosted.org/packages/86/b7/db45cbe92aec6eb2a469dadc6b8220fe70678063d640063e1f74bac9c316/django-dynaconf-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-11 19:58:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mhsiddiqui",
    "github_project": "django-dynaconf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-dynaconf"
}
        
Elapsed time: 0.18225s