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


Download files

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

Source Distribution

DjangoSecretKey-0.1.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

DjangoSecretKey-0.1.0-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

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