Skip to content

Instantly share code, notes, and snippets.

@swinton
Created February 5, 2015 22:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swinton/d44fde5d323473ce8be7 to your computer and use it in GitHub Desktop.
Save swinton/d44fde5d323473ce8be7 to your computer and use it in GitHub Desktop.
"""
How Django generates SECRET_KEYs for new Django projects.
See:
https://github.com/django/django/blob/1.7.1/django/core/management/commands/startproject.py#L27
"""
from django.utils.crypto import get_random_string
# Create a random secret_key
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
secret_key = get_random_string(50, chars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment