Skip to main content

Django SECRET_KEY management

Project description

https://travis-ci.org/blinglnav/djangosecretkey.svg?branch=master https://coveralls.io/repos/github/blinglnav/djangosecretkey/badge.svg?branch=master

In Django web framework, it has SECRET_KEY variable in settings.py this variable use to manage credential values like session.

Therefore, SECRET_KEY value have to store outside of settings.py and use this value to read from file or environment variables.

Install

pip instal djangosecretkey

This project has not any dependencies. (For test, needs pytest package) You cannot download yet

Usage

Use file to store secret key

In settings.py

import os
from secret_key import secret_key
# ...
SECRET_KEY = secret_key.from_file(os.path.join(BASE_DIR, 'secret_key'))

If use .from_file() method, you have to secert key file add to .gitignore

Use env to store secret key

In settings.py

import os
from secret_key import secret_key
# ...
SECRET_KEY = secret_key.from_env('env_name')

default env_name is “DJANGO_SECRET_KEY”

Generate secret key manually

You can also generate secret key manually.

import os
from secret_key import secret_key
# ...
SECRET_KEY = secret_key.generate()

But, this method not recommanded.

Project details


Release history Release notifications

This version
History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
DjangoSecretKey-0.1.0-py3-none-any.whl (3.9 kB) Copy SHA256 hash SHA256 Wheel py3
DjangoSecretKey-0.1.0.tar.gz (2.8 kB) Copy SHA256 hash SHA256 Source None

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