Start a new topic

Deploying with environmental variables

In my settings.py file I use an environmental variable, like this:


 

MONGO_URI = os.environ['MONGO_URI']

However, when I deploy the project I get an error about this key (MONGO_URI) not existing. 


I know I can set this key in Scapringhub settings, but I have to comment the line out for the deploy to work. Is there any way around this?


1 Comment

Found the solution: just do


 

MONGO_URI = os.environ.get('MONGO_URI')

 This way there will be no error due to missing variable

Login to post a comment