Created
June 26, 2019 13:46
-
-
Save julianobarbosa/9368f55c0a51540d1fff90a676f26680 to your computer and use it in GitHub Desktop.
contrib env_gen.py - Create environment variables to use with settings of Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Django SECRET_KEY generator. | |
""" | |
from django.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
CONFIG_STRING = """ | |
DEBUG=True | |
SECRET_KEY=%s | |
ALLOWED_HOSTS=127.0.0.1, .localhost | |
#DATABASE_URL=postgres://USER:PASSWORD@HOST:PORT/NAME | |
#DEFAULT_FROM_EMAIL= | |
#EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend | |
#EMAIL_HOST= | |
#EMAIL_PORT= | |
#EMAIL_USE_TLS= | |
#EMAIL_HOST_USER= | |
#EMAIL_HOST_PASSWORD= | |
""".strip() % get_random_string(50, chars) | |
# Writing our configuration file to '.env' | |
with open('.env', 'w') as configfile: | |
configfile.write(CONFIG_STRING) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment