mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
add support for adding reference links to values
Now Value classes accept a 'help_reference' keyword which will get printed when a ValueRetrievalError or ValueProcessingError occurs
This commit is contained in:
parent
50ac28b667
commit
12ffda4760
3 changed files with 7 additions and 2 deletions
|
|
@ -19,6 +19,9 @@ def extract_explanation_lines_from_value(value_instance: 'Value') -> List[str]:
|
|||
if value_instance.help_text is not None:
|
||||
result.append(f"Help: {value_instance.help_text}")
|
||||
|
||||
if value_instance.help_reference is not None:
|
||||
result.append(f"Reference: {value_instance.help_reference}")
|
||||
|
||||
if value_instance.destination_name is not None:
|
||||
result.append(f"{value_instance.destination_name} is taken from the environment variable "
|
||||
f"{value_instance.full_environ_name} as a {type(value_instance).__name__}")
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class Value:
|
|||
|
||||
def __init__(self, default=None, environ=True, environ_name=None,
|
||||
environ_prefix='DJANGO', environ_required=False, help_text=None,
|
||||
*args, **kwargs):
|
||||
help_reference=None, *args, **kwargs):
|
||||
if isinstance(default, Value) and default.default is not None:
|
||||
self.default = copy.copy(default.default)
|
||||
else:
|
||||
|
|
@ -72,6 +72,7 @@ class Value:
|
|||
self.environ_required = environ_required
|
||||
self.destination_name = None
|
||||
self.help_text = help_text
|
||||
self.help_reference = help_reference
|
||||
|
||||
def __str__(self):
|
||||
return str(self.value)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ from configurations import Configuration, values
|
|||
class Base(Configuration):
|
||||
# Django settings for test_project project.
|
||||
|
||||
DEBUG = values.BooleanValue(True, environ=True, help_text="Enables or disables django debug mode")
|
||||
DEBUG = values.BooleanValue(True, environ=True, help_text="Enables or disables django debug mode",
|
||||
help_reference="https://docs.djangoproject.com/en/dev/ref/settings/#debug")
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@example.com'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue