Use Django's get_random_secret_key instead of own code.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import management
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
|
||||
from ...settings import setting_local_settings_filename
|
||||
|
||||
@@ -14,11 +14,6 @@ from .literals import SETTING_FILE_TEMPLATE
|
||||
class Command(management.BaseCommand):
|
||||
help = 'Creates a local settings file with a random secret key.'
|
||||
|
||||
@staticmethod
|
||||
def _generate_secret_key():
|
||||
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
||||
return get_random_string(50, chars)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
path = os.path.join(settings.BASE_DIR, 'settings', '{}.py'.format(setting_local_settings_filename.value))
|
||||
if os.path.exists(path):
|
||||
@@ -26,5 +21,5 @@ class Command(management.BaseCommand):
|
||||
else:
|
||||
with open(path, 'w+') as file_object:
|
||||
file_object.write(
|
||||
SETTING_FILE_TEMPLATE.format(Command._generate_secret_key())
|
||||
SETTING_FILE_TEMPLATE.format(get_random_secret_key())
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user