1. Copy all sensitive data to a separate module and import to your main settings file:
This is the easiest and most straight forward method. it involves copying the sensitive parts of your settings file to a different then include them to your main settings file using the import *. then add your secret settings to .gitignore so it doesn't find its way to your public repository.
2. Using environment variables
Every operating system supported by Django (and Python) provides the easy capability to create environment variables. To do this on windows, open your settings file and locate the SECRET_KEY line, then copy the value of the secret key(including the quotes), then open your command prompt and type
setx SECRET_KEY 'your secret key'
then replace your secret key with
SECRET_KEY = os.environ['SECRET_KEY']
Now test the installation to make sure all is working well. at the terminal, type python manage.py runserver. If the server starts with no errors then the changes was successful.
0 comments:
Post a Comment