From 7a651446413b2391284fd13f7df9b9c6ae1b78a7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 24 Apr 2019 16:08:59 +1000 Subject: [PATCH] Use random.choice instead of random.choices - Allows compatibility with python3.5 --- InvenTree/key.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/InvenTree/key.py b/InvenTree/key.py index 20471a3a9f..60ff54df18 100644 --- a/InvenTree/key.py +++ b/InvenTree/key.py @@ -7,7 +7,9 @@ import os fn = 'secret_key.txt' def generate_key(): - return ''.join(random.choices(string.digits + string.ascii_letters + string.punctuation, k=50)) + options = string.digits + string.ascii_letters + string.punctuation + key = ''.join([random.choice(options) for i in range(50)]) + return key if __name__ == '__main__': @@ -15,6 +17,6 @@ if __name__ == '__main__': path = os.path.dirname(os.path.realpath(__file__)) key_file = os.path.join(path, fn) - with open(key_file, 'w') as key: - key.write(generate_key()) + with open(key_file, 'w') as kf: + kf.write(generate_key()) print('Generated SECRET_KEY to {f}'.format(f=key_file)) \ No newline at end of file