mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Added a function for SECRET_KEY generation logic.
This commit is contained in:
parent
f2b45ddd99
commit
408c406abc
@ -2,7 +2,8 @@ from importlib import import_module
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.templates import TemplateCommand
|
||||
from django.utils.crypto import get_random_string
|
||||
|
||||
from ..utils import get_random_secret_key
|
||||
|
||||
|
||||
class Command(TemplateCommand):
|
||||
@ -27,7 +28,6 @@ class Command(TemplateCommand):
|
||||
project_name)
|
||||
|
||||
# Create a random SECRET_KEY to put it in the main settings.
|
||||
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
||||
options['secret_key'] = get_random_string(50, chars)
|
||||
options['secret_key'] = get_random_secret_key()
|
||||
|
||||
super(Command, self).handle('project', project_name, target, **options)
|
||||
|
@ -5,6 +5,7 @@ import sys
|
||||
from subprocess import PIPE, Popen
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_text
|
||||
|
||||
from .base import CommandError
|
||||
@ -75,3 +76,11 @@ def find_command(cmd, path=None, pathext=None):
|
||||
if os.path.isfile(fext):
|
||||
return fext
|
||||
return None
|
||||
|
||||
|
||||
def get_random_secret_key():
|
||||
"""
|
||||
Return a 50 character random string usable as a SECRET_KEY setting value.
|
||||
"""
|
||||
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
||||
return get_random_string(50, chars)
|
||||
|
Loading…
Reference in New Issue
Block a user