-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add django-constance to the cookiecutter options. Update README. Add django-constance how-to. Update django-cookiecutter project inputs reference. Add example setting in base.py. Add tests for the option. closes #299
- Loading branch information
Showing
10 changed files
with
206 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,10 @@ | |
"False" | ||
], | ||
"SITE_ID": "1", | ||
"use_constance": [ | ||
"n", | ||
"y" | ||
], | ||
"deploy_with_docker": [ | ||
"n", | ||
"y", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
.. include:: /extras.rst.txt | ||
.. highlight:: rst | ||
.. index:: how-to-constance ; Index | ||
|
||
.. _how-to-constance: | ||
|
||
========= | ||
Constance | ||
========= | ||
|
||
|
||
django-constance provides the convenience of dynamic site settings, | ||
accessible in the Admin panel. | ||
|
||
There are many configuration options available; for more, see further | ||
reading below. | ||
|
||
django-cookiecutter employs the django-constance database configuration option. | ||
|
||
Adding dynamic settings is done in `config/settings/base.py`. | ||
|
||
|
||
.. code-block:: python | ||
:linenos: | ||
CONSTANCE_CONFIG = { | ||
'THE_ANSWER': (42, 'Answer to the Ultimate Question of Life, ' | ||
'The Universe, and Everything', int), | ||
} | ||
In the example above, provided in `config/settings/base.py`, | ||
|
||
`THE_ANSWER`: is the dynamic settings key. | ||
|
||
`42`: is the default value if `THE_ANSWER` is not found in the backend. | ||
|
||
`Help` text displayed in the Admin panel. | ||
'Answer to the Ultimate Question of Life, ' | ||
'The Universe, and Everything' | ||
|
||
`int`: optional indicates the value type. | ||
|
||
The supported types are: | ||
|
||
- bool | ||
- int | ||
- float | ||
- Decimal | ||
- str | ||
- datetime | ||
- date | ||
- time | ||
|
||
|
||
Changing Settings | ||
_________________ | ||
|
||
Settings you have provided in `base.py`, shown above, can be changed in the | ||
Admin panel. | ||
|
||
**Select** `Config` in the Constance section. | ||
|
||
.. image:: ../_static/imgs/how-tos/admin-constance.png | ||
:alt: Django Admin Constance | ||
|
||
|
||
| | ||
**Change** the setting. | ||
|
||
The example dynamic setting provided with django-cookiecutter is below. | ||
|
||
.. image:: ../_static/imgs/how-tos/admin-constance-setting.png | ||
:alt: Django Admin Constance | ||
|
||
| | ||
Further Reading | ||
--------------- | ||
|
||
For additional Constance and custom configurations. | ||
|
||
`Constance config quickstart`_. | ||
|
||
Constance provides several backend options to store configuration values. | ||
By default, it uses the `Redis` backend. django-cookiecutter uses `database`. | ||
|
||
`Constance backends`_. | ||
|
||
Use `override_config` class for testing how your app behaves with different config values. | ||
|
||
`Constance config for testing`_. | ||
|
||
|
||
.. _Constance config quickstart: https://django-constance.readthedocs.io/en/latest/index.html | ||
.. _Constance backends: | ||
.. _Constance config for testing: https://django-constance.readthedocs.io/en/latest/testing.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
{{cookiecutter.git_project_name}}/config/requirements/base.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters