2👍
✅
os.environ.get('MBAIR', False)
searches for an environmental variable called MBAIR. If it does not exist, it returns False.
So when you use that if statement, you’re searching for an environmental variable that you’re assuming is only set on a heroku server. If found, it sets DEBUG to FALSE and then uses dj_database_url.config to create the database configuration dictionary with the following arguments:
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
Otherwise it uses your manually defined database settings.
edit: you can try this out like this:
>>> import os
>>> os.environ['testvariable'] = "dookie"
>>> os.environ.get('testvariable', False)
'dookie'
>>> os.environ.get('MBAIR', False)
False
>>> os.environ.get('MBAIR', "Hooha")
'Hooha'
Also, False
can be replaced with just about anything.
Source:stackexchange.com