From 0ac83b6c0936e72255d61223bc0adf5752e69293 Mon Sep 17 00:00:00 2001 From: Floriel Fedry Date: Mon, 13 Dec 2021 12:39:35 +0000 Subject: [PATCH] use env variable for django secret key --- README.md | 5 +++-- charting_library_charts/settings.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 533a821..e191211 100644 --- a/README.md +++ b/README.md @@ -13,5 +13,6 @@ Python 3x, pip, Django, Postgresql 3. Go to your charts storage folder and run `pip install -r requirements.txt`. Unix users : you have to have python-dev package to install `psycopg2`. 4. Create an empty database in Postgres (using either command line or `pgadmin`). Go to `charting_library_charts` folder and set up your database connection in `settings.py` (see `DATABASES` @ line #12). 5. Run `python manage.py migrate`. This will create database schema without any data. -6. Run `python manage.py runserver` to run *TEST* instance of your database. Use some other stuff (i.e., Gunicorn) for your production environment. - +6. Generate a secret key by running `python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'` +7. Set your secret key to your environment variables `export SECRET_KEY='...'` +8. Run `python manage.py runserver` to run *TEST* instance of your database. Use some other stuff (i.e., Gunicorn) for your production environment. diff --git a/charting_library_charts/settings.py b/charting_library_charts/settings.py index 7845258..99d33ad 100755 --- a/charting_library_charts/settings.py +++ b/charting_library_charts/settings.py @@ -83,7 +83,7 @@ STATICFILES_FINDERS = ( ) # Make this unique, and don't share it with anybody. -SECRET_KEY = 'c5-%u0l1*(dj@u33!5*o_gtti0)kkh$m%i#@!(!$d%779kaa&b' +SECRET_KEY = os.getenv('SECRET_KEY', 'c5-%u0l1*(dj@u33!5*o_gtti0)kkh$m%i#@!(!$d%779kaa&b') # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = (