Reputation: 302
[USING PYCHARM]
I'm trying to use .env
file details in settings.py
using python-decouple
. decouple
installed perfectly but when I tried to import it, it raises a warning: Package containing module 'decouple' is not listed in project requirements
.
you can see the package details from here:
https://pypi.org/project/python-decouple/3.1/
warning i'm getting while importing decouple
error in terminal : raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: EMAIL_BACKEND not found. Declare it as envvar or define a default value.
.env
file
export EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
export EMAIL_HOST=smtp.gmail.com
export [email protected]
export EMAIL_USE_TLS=True
export EMAIL_PORT=587
export EMAIL_HOST_PASSWORD=xxxxxxxxx;
settings.py
EMAIL_BACKEND = config('EMAIL_BACKEND')
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_USE_TLS = config('EMAIL_USE_TLS')
EMAIL_PORT = config('EMAIL_PORT')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
I tried creating requirements.txt and added python-decouple==3.3
in it but it still not working.
one more thing i'm using pipenv
package was that can be the issue?
Upvotes: 0
Views: 1417
Reputation: 278
Change your .env
file to
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
[email protected]
EMAIL_USE_TLS=True
EMAIL_PORT=587
EMAIL_HOST_PASSWORD=xxxxxxxxx;
Remove export keywords
from your .env
file.
Upvotes: 1