-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add Support for Prefix in Env Constructor #384
Comments
environs already supports prefixes: https://github.com/sloria/environs?tab=readme-ov-file#handling-prefixes |
I know environs already supported, but it requires using the context manager approach. I am using it in Django to read settings, and all my settings start with DJANGO_ prefix. Following the previous implementation, it was not very convenient. Therefore, I proposed allowing users to pass in a prefix at the beginning. |
@arthurc0102 why is the context manager less convenient? |
The current usage is as follows (part of env = environs.Env()
env.read_env(path=str(BASE_DIR / ".env"), recurse=False)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", default=(MODE == "local"))
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[]) All environment variables here start with |
yeah, I suppose if all your environment variables have the same prefix, the ctor argument is slightly more convenient and avoids having to indent the whole file. i've implemented this in #387 |
Thank you for implementing this feature and releasing a new version! |
Hi,
I have a use case where all required environment variables need to share a common prefix. To simplify configuration and avoid redundancy, I propose adding a
prefix
argument to theEnv
constructor. For example:This feature could enhance the usability of
environs
for projects that follow naming conventions for environment variables.If this idea aligns with the project's direction, I'd be happy to implement it and submit a pull request.
The text was updated successfully, but these errors were encountered: