Skip to main content

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()

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.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

django_generate_secret_key-1.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_generate_secret_key-1.0.0.tar.gz
Algorithm Hash digest
SHA256 af227b061d4a338eab51fb4d232cffff76cf1688c24a0a602ee1bd81c52cbc1c
MD5 33926226cdcdd965b72a2359b6e2e2b6
BLAKE2b-256 30c88b3f229cbe09ff2d02a76c24d7d97cfa4a50f2f09ce051fe8bb4a83803f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_generate_secret_key-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7899fd9c219c04d74b2d9bd39b99e03eacaba1e175685fc70e9bae45bddecf85
MD5 29c5535d6f48cac57e39a6cc458ca2aa
BLAKE2b-256 393e00ba4ac825aca3cc74696718d23fa0d8489dd78b4b9c0d544bf004f5dda5

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