Skip to content
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

DOTENV - Using environ_name strange behevior #380

Open
alon-p opened this issue Dec 18, 2023 · 1 comment
Open

DOTENV - Using environ_name strange behevior #380

alon-p opened this issue Dec 18, 2023 · 1 comment

Comments

@alon-p
Copy link

alon-p commented Dec 18, 2023

Hi
First of all, thanks for making django-configurations. It's great! Thank you

I've noticed a weird bug while using the DOTENV in my configurations
I have an .env file with this value

.env

MY_URL=http://some.domain.com

And in my settings.py file I define this

settings.py

class Base(Configuration):
    BASE_DIR = Path(__file__).resolve().parent.parent
    DOTENV = os.path.join(BASE_DIR, '.env')
    ....

class Development(Base):
    MY_URL = values.Value(environ_name="MY_URL")

When I run

python manage.py runserver

Everything work as expected, MY_URL gets its value from the .env file.

But when I run other manage.py commands (I haven't checked with all of them)

python manage.py migrate

MY_URL is None.

For now I can workaround that by setting environ_prefix to an empty string instead of using environ_name.

settings.py

class Development(Base):
    MY_URL = values.Value(environ_prefix="")

I've tried to dig through the source code to see if I can fix this but so far I haven't.
If I find something, I'll try opening a PR.

Any Ideas where to look?

@eduardo-boutiquenumerique

As far as I understand, the variable should be DJANGO_MY_URL in your .env file. When you set environ_prefix="", you are telling django-configurations to not add the prefix "DJANGO_"

I started using the values now and am having some issues with it as well (check #379 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants