Jul 30, 2016 Generate a new Django SECRETKEY. GitHub Gist: instantly share code, notes, and snippets. A good point is made in comment:9 that one potential problem is when moving from a 'single' to 'multi' deployment (eg, if a new dev is unfamiliar with SECRETKEY they might be caught by surprise). I think django.conf.Settings should generate SECRETKEY based on a new setting called SECRETKEYFILE.
![New New](/uploads/1/2/5/8/125871716/769978649.png)
Simple Django application that adds a new command:
This will generate a new file
secretkey.txt
containing a random Django secretkey. In your production settings file, replace the hardcoded key by:You can avoid hardcoding the path of the key by using:
Python Generate Secret Key
Install
Generate New Secret Key Django Full
You can install this package from PyPi:
Then you will need to add it to the Django's INSTALLED_APPS setting:
![Generate New Secret Key Django Generate New Secret Key Django](/uploads/1/2/5/8/125871716/631485998.png)
You can now use
Run this command once in your local environment, and every time you deploy your app (on the remote host), to make sure the file exists.