python-decouple: decouple.UndefinedValueError: SECRET_KEY not found.

Hi,

I am getting following error-

raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option)) decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.

Issue seems with the secret key starting with equal to (=) sign. For example with below secret key: SECRET_KEY = =xg583qt1rc*lec39dy6mtdlg@#v+m0a51no&2@l9fz^nkh&1f

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15

Most upvoted comments

en settings.py completa la línea como sale debajo: SECRET_KEY = config(‘SECRET_KEY’, default=‘mydefaultvalue’)

@enyfour5 .env is searched starting on the main module directory going upwards on the directory tree. You can specify a file by:

from decouple import Config, RepositoryEnv

config = Config(RepositoryEnv("path/to/env_file"))

is it possible to create a “.env” file in a dist folder? I keep getting this error and I created the “.env” file in my dist folder but apparently it’s not reading it. Any help here is appreciated. I used pyinstaller to create an exe of my python script but keep getting that error. It works outside of my dist folder but not inside my dist folder.