Skip to content

Instantly share code, notes, and snippets.

@joshsee
Created March 20, 2015 03:32
Show Gist options
  • Save joshsee/8c495c2da9b423d42e8d to your computer and use it in GitHub Desktop.
Save joshsee/8c495c2da9b423d42e8d to your computer and use it in GitHub Desktop.
Django Secret Key Script
"""
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
"""
import string
import random
# Get ascii Characters numbers and punctuation (minus quote characters as they could terminate string).
chars = ''.join([string.ascii_letters, string.digits, string.punctuation]).replace('\'', '').replace('"', '').replace('\\', '')
SECRET_KEY = ''.join([random.SystemRandom().choice(chars) for i in range(50)])
print SECRET_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment