Skip to main content

A Django application with a command to generate a Django secret key

Project description

https://badge.fury.io/py/django_generate_secret_key.svg

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_generate_secret_key-1.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

django_generate_secret_key-1.0.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file django_generate_secret_key-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django_generate_secret_key-1.0.1.tar.gz
Algorithm Hash digest
SHA256 eba0c1ad120825f8d7f19473a1c0b8a0225a66e6e4035bfcf0d6b611182b38c1
MD5 e7ae83f29414703e696ae021c6c3f525
BLAKE2b-256 bdc36a5953e0c22c2207e52f3275a95cea88c5102addb9f518f790ee12175c74

See more details on using hashes here.

File details

Details for the file django_generate_secret_key-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_generate_secret_key-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4128da27429cebcdd4497dd6ac10198b0f9a3f4ee17267e9c426e249d640f2d
MD5 cda327c86300e41b452313a3583eac93
BLAKE2b-256 5c3d5b6d6a2120085b87ff74c2a9d9b1e5fc1ec3e330e9f67e9e600148b91f7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page