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.
Release files for DjangoSecretKey 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| DjangoSecretKey-0.1.0.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| DjangoSecretKey-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / DjangoSecretKey-0.1.0.tar.gz
| Download URL | DjangoSecretKey-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17aae43b852cd04ff92ec247ba908e0d6862b9b054a0fc3aeeaf492dcf2cf4d3
|
|
BLAKE2b-256 checksum How to use checksums |
4116ab8239b86b22f84ce2cefddc86637dec4bba317af20eda77454e7aca471a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
|
Release files / DjangoSecretKey-0.1.0-py3-none-any.whl
| Download URL | DjangoSecretKey-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1570b1a2395194041f30a35f2dcafc0ae21e0b47ef9130d7900fc0de554b66a
|
|
BLAKE2b-256 checksum How to use checksums |
1522018d196d4a41fb63b04d14c4c918b84a7bc636dc5f9423f052454a007894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
|