Renamed key.py to keygen.py

This commit is contained in:
Oliver Walters 2019-04-27 17:03:37 +10:00
parent 8d0df6654c
commit 0cec12085d
2 changed files with 15 additions and 4 deletions

View File

@ -1,4 +1,8 @@
# Generate a SECRET_KEY file
"""
Module keygen
=============
This module generates a Django SECRET_KEY file to be used by manage.py
"""
import random
import string
@ -10,9 +14,16 @@ KEY_FN = 'secret_key.txt'
KEY_DIR = os.path.dirname(os.path.realpath(__file__))
def generate_key():
def generate_key(length=50):
"""
Generate a random string
:param length: Number of characters in returned string (default=50)
:returns: Randomized secret key string
"""
options = string.digits + string.ascii_letters + string.punctuation
key = ''.join([random.choice(options) for i in range(50)])
key = ''.join([random.choice(options) for i in range(length)])
return key

View File

@ -17,7 +17,7 @@ migrate:
install:
pip install -U -r requirements.txt
python InvenTree/key.py
python InvenTree/keygen.py
setup: install migrate