First install this
pip install -U python-dotenv
create a .env file, anywhere should be fine but testing save it in the root of your django project.
touch .env
emacs .env
username=youremail@gmail.com
password=yourGmailGeneratedAppPassword
In your Django Settings.py
import os
from dotenv import load_dotenv
load_dotenv()
At the bottom of settings.py
username = os.environ.get('username')
password = os.environ.get('password')
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = username
EMAIL_HOST_PASSWORD = password
EMAIL_USE_TLS = True
#EMAIL_USE_SSL = True