Skip to content

Instantly share code, notes, and snippets.

@dubirajara
Created June 21, 2018 15:51
Show Gist options
  • Save dubirajara/6d6d922b4ed1adb6021511c26b651954 to your computer and use it in GitHub Desktop.
Save dubirajara/6d6d922b4ed1adb6021511c26b651954 to your computer and use it in GitHub Desktop.
Generate .env config file
from django.core.management import utils
CONFIG_ENV = f"""
SECRET_KEY={utils.get_random_secret_key()}
DEBUG=True
ALLOWED_HOSTS=*
DEFAULT_FROM_EMAIL=admin@exemple.com
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_HOST=localhost
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_PORT=25
EMAIL_USE_TLS=False
"""
# Writing our configuration file to '.env'
with open('myproject/.env', 'w') as configfile:
configfile.write(CONFIG_ENV)
print('Created the .env file successfully.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment