#!/usr/bin/env python

"""
Django SECRET_KEY generator.
"""
from django.utils.crypto import get_random_string


chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'

CONFIG_STRING = """
SECRET_KEY={}
DEBUG=True
ALLOWED_HOSTS=*
#DATABASE_URL=postgres://postgresuser:postgrespass@db:5432/ideasdb

#EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
#EMAIL_HOST=localhost
#EMAIL_HOST_USER=
#EMAIL_HOST_PASSWORD=
#EMAIL_PORT=25
#EMAIL_USE_TLS=False

# SENDGRID SETTINGS
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.sendgrid.com
SENDGRID_API_KEY=
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_PORT=587
EMAIL_USE_TLS=True


# DJANGO SOCIAL-AUTH SETTINGS
SOCIAL_AUTH_FACEBOOK_KEY=
SOCIAL_AUTH_FACEBOOK_SECRET=
SOCIAL_AUTH_TWITTER_KEY=
SOCIAL_AUTH_TWITTER_SECRET=

#DJANGO RECAPTCHA
RECAPTCHA_PUBLIC_KEY=
RECAPTCHA_PRIVATE_KEY=
""".strip().format(get_random_string(50, chars))

# Writing our configuration file to '.env'
with open('myideas/.env', 'w') as configfile:
    configfile.write(CONFIG_STRING)
    print('Created the .env file successfully.')

@@ -69,108 +69,76 @@
 ngo.
-utils.crypto import get_random_string%0A%0A%0Achars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%25%5E&*(-_=+)'
+core.management import utils%0A%0A%0Achars = utils.get_random_secret_key()
 %0A%0ACO
@@ -151,16 +151,17 @@
 TRING = 
+f
 %22%22%22%0ASECR
@@ -168,16 +168,45 @@
 ET_KEY=%7B
+utils.get_random_secret_key()
 %7D%0ADEBUG=
@@ -863,53 +863,8 @@
 %0A%22%22%22
-.strip().format(get_random_string(50, chars))
 %0A%0A# 

refactor secret key generator