2

I'm using Docker containers with Django. In my container I'm using environment variables via .env file

container_name:
    env_file: .env

I have echoe'd SECRET_KEY after the container is up and it shows the correct value set in .env file.

The problem is in my settings. When I do the following...

import environ

env = environ.Env()

SECRET_KEY = env('SECRET_KEY', default='some_other_value')

... I was expecting "try to read 'SECRET_KEY' from the OS, but if you can't find it set it to 'some_other_value'. It turns out it isn't, having the following output:

get 'SECRET_KEY' casted as 'None' with default '<NoValue>'

On the other hand, if I do os.environ.get('SECRET_KEY') it gets the correct value.

What am I doing wrong with django-environ package?

Eduardo Gomes
  • 492
  • 3
  • 11

0 Answers0