Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Module and CLI tool for handling Django keys.

Project description

This Python module is used to generate and handle secret keys for Django.

  • It comes with a CLI tool to generate secret keys for Django.
  • It can be used to store and retrieve Django’s secret key.

Command-Line Tool

This module also implements a CLI tool, that can be used to generate secret keys for Django. For more information, use the following command:

code-block :: console

$ python3 -m djangokeys –help

For example, one could generate a new key and store it in the file secret.key by using the command below:

code-block :: console

$ python3 -m djangokeys –length 128 > secret.key

Python Module

The python module also provides the functionality for reading the secret from a file. In the example below, the secret key is stored in the file data/secret.txt relative to Django’s file. By setting the strict parameter to True, it is required that the file exists. If it cannot be found, an exception is raised.

code-block :: python

# file: config/

import djangokeys

SECRET_KEY = djangokeys.retrieve_secret_key_from_file(
os.path.join(BASE_DIR, “data/secret.txt”), strict=True)

If the strict parameter is not provided, and the file is not found, a new secret key is automatically generated, and stored in a new file with the given filepath.

Project details

Download files

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

Files for djangokeys, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size djangokeys-0.1.1-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size djangokeys-0.1.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page