Skip to content

Allow to globally configure environ_prefixΒ #240

@husio

Description

@husio

In the current implementation every declared value is mapped to a shell variable with a DJANGO_ prefix by default. Prefix value can be overwritten and it must be done per variable declaration.

It would be amazing to be able to declare the default prefix value globally for the whole configuration instead of specifying the same environment prefix for every variable declaration. I think this could be implemented in many ways, ensuring backward compatibility. For example by providing a decorator for the configuration class:

@use_environ_prefix(None)
class Base(Configuration):
    # If no environ_prefix is provided, default is used.
    # No prefix. Use FOOBAR_KEY environment valiable.
    FOOBAR_KEY = values.SecretValue()

    # Exiplicit declaration of the environ_prefix for the value always wins.
    # Use MYAPP_DEBUG environment variable.
    DEBUG = values.BooleanValue(False, environ_prefix="MYAPP")

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions