differentreality / supplies_tracker

Django project for tracking home and office supplies
GNU General Public License v3.0
5 stars 10 forks source link

Use environment variables in the settings file #72

Closed tim-schilling closed 6 years ago

tim-schilling commented 6 years ago

You absolutely need to change your secret key (some reasons why) and then switch it with something similar to:

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

Do the same for your google API key.

angeanto commented 6 years ago

@tim-schilling There's a default way to do this or just change the key in everything i want ?

tim-schilling commented 6 years ago

To get a new key:

python manage.py shell -c 'from django.core.management import utils; print(utils.get_random_secret_key())'
angeanto commented 6 years ago

i got a key and passed it to pythonanywhere although i changed it to string 'secret' here in github . #74 ( commit : secret key fixed ) @tim-schilling Is this what you suggested for ?

robertpro commented 6 years ago

You have to save a environment variable like this in your linux server:

export SECRET_KEY="S3CR3T"

And in your settings file load that environment variable like this:

import os
SECRET_KEY = os.environ.get('SECRET_KEY')

There is a way in PythonAnywhere to set an environment variable.

angeanto commented 6 years ago

I think it works the way i did it @robertpro

robertpro commented 6 years ago

It works, but it is not correct :( @angeanto