Polished and fixed custom user model

This commit is contained in:
Keannu Christian Bernasol 2023-06-26 20:36:58 +08:00
parent e19c88527a
commit 87d30a0ecc
6 changed files with 93 additions and 21 deletions

View file

@ -31,11 +31,27 @@ DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
# Email credentials
EMAIL_HOST = ''
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = ''
if (DEBUG == True):
EMAIL_HOST = str(os.getenv('DEV_EMAIL_HOST'))
EMAIL_HOST_USER = str(os.getenv('DEV_EMAIL_HOST_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('DEV_EMAIL_HOST_PASSWORD'))
EMAIL_PORT = str(os.getenv('DEV_EMAIL_PORT'))
else:
EMAIL_HOST = str(os.getenv('PROD_EMAIL_HOST'))
EMAIL_HOST_USER = str(os.getenv('PROD_EMAIL_HOST_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('PROD_EMAIL_HOST_PASSWORD'))
EMAIL_PORT = str(os.getenv('PROD_EMAIL_PORT'))
# Application definition
INSTALLED_APPS = [
'accounts',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -45,6 +61,7 @@ INSTALLED_APPS = [
'rest_framework',
'djoser',
'rest_framework.authtoken',
'accounts',
]
@ -108,19 +125,6 @@ DJOSER = {
},
}
# Email credentials
if (DEBUG == True):
EMAIL_HOST = str(os.getenv('DEV_EMAIL_HOST'))
EMAIL_HOST_USER = str(os.getenv('DEV_EMAIL_HOST_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('DEV_EMAIL_HOST_PASSWORD'))
EMAIL_PORT = str(os.getenv('DEV_EMAIL_PORT'))
else:
EMAIL_HOST = str(os.getenv('PROD_EMAIL_HOST'))
EMAIL_HOST_USER = str(os.getenv('PROD_EMAIL_HOST_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('PROD_EMAIL_HOST_PASSWORD'))
EMAIL_PORT = str(os.getenv('PROD_EMAIL_PORT'))
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators