A Django application with a command to generate a Django secret key
Project description
Django generate-secret-key application
======================================
Simple Django application that adds a new command:
python manage.py generate_secret_key [--replace] [secretkey.txt]
This will generate a new file `secretkey.txt` containing a random Django secret
key. In your production settings file, replace the hardcoded key by:
# Use a separate file for the secret key
with open('/path/to/the/secretkey.txt') as f:
SECRET_KEY = f.read().strip()
You can avoid hardcoding the path of the key by using:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Use a separate file for the secret key
with open(os.path.join(BASE_DIR, 'secretkey.txt')) as f:
SECRET_KEY = f.read().strip()
======================================
Simple Django application that adds a new command:
python manage.py generate_secret_key [--replace] [secretkey.txt]
This will generate a new file `secretkey.txt` containing a random Django secret
key. In your production settings file, replace the hardcoded key by:
# Use a separate file for the secret key
with open('/path/to/the/secretkey.txt') as f:
SECRET_KEY = f.read().strip()
You can avoid hardcoding the path of the key by using:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Use a separate file for the secret key
with open(os.path.join(BASE_DIR, 'secretkey.txt')) as f:
SECRET_KEY = f.read().strip()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_generate_secret_key-1.0.0.tar.gz
.
File metadata
- Download URL: django_generate_secret_key-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
af227b061d4a338eab51fb4d232cffff76cf1688c24a0a602ee1bd81c52cbc1c
|
|
MD5 |
33926226cdcdd965b72a2359b6e2e2b6
|
|
BLAKE2b-256 |
30c88b3f229cbe09ff2d02a76c24d7d97cfa4a50f2f09ce051fe8bb4a83803f0
|
File details
Details for the file django_generate_secret_key-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_generate_secret_key-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7899fd9c219c04d74b2d9bd39b99e03eacaba1e175685fc70e9bae45bddecf85
|
|
MD5 |
29c5535d6f48cac57e39a6cc458ca2aa
|
|
BLAKE2b-256 |
393e00ba4ac825aca3cc74696718d23fa0d8489dd78b4b9c0d544bf004f5dda5
|