Keep Secret Keys Out

前端 未结 7 858
情话喂你
情话喂你 2020-12-07 21:02

One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem:

  • Secrets often shoul
7条回答
  •  遥遥无期
    2020-12-07 21:38

    I doing my Django projects using Windows 7 and Powershell, so for me it was slightly different to set the environment variable. Once it was set though, I just did the following in my settings.py file:

    import os
    SECRET_KEY = os.environ["SOME_SECRET_KEY"]
    

    To set a environment variable in Windows using PowerShell follow the instructions in the link below:

    http://technet.microsoft.com/en-us/library/ff730964.aspx

提交回复
热议问题