secrets and mail config in production
This commit is contained in:
		
							parent
							
								
									9669d10e30
								
							
						
					
					
						commit
						abd7885abf
					
				|  | @ -15,17 +15,44 @@ from pathlib import Path | |||
| # Build paths inside the project like this: BASE_DIR / 'subdir'. | ||||
| BASE_DIR = Path(__file__).resolve().parent.parent | ||||
| 
 | ||||
| # mails in development go to stdout | ||||
| EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||||
| # mails in production goes to mailserver | ||||
| EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||||
| 
 | ||||
| EMAIL_HOST = '10.0.6.25' | ||||
| EMAIL_PORT = '25' | ||||
| 
 | ||||
| # Build paths inside the project like this: BASE_DIR / 'subdir'. | ||||
| BASE_DIR = Path(__file__).resolve().parent.parent | ||||
| 
 | ||||
| # get secrets | ||||
| with open(os.path.join(BASE_DIR, 'secrets.json')) as secrets_file: | ||||
|     secrets = json.load(secrets_file) | ||||
| 
 | ||||
| def get_secret(setting, secrets=secrets): | ||||
|     """Get secret setting or fail with ImproperlyConfigured""" | ||||
|     try: | ||||
|         return secrets[setting] | ||||
|     except KeyError: | ||||
|         raise ImproperlyConfigured("Set the {} setting".format(setting)) | ||||
| 
 | ||||
| 
 | ||||
| # Quick-start development settings - unsuitable for production | ||||
| # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ | ||||
| 
 | ||||
| # SECURITY WARNING: keep the secret key used in production secret! | ||||
| SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' | ||||
| SECRET_KEY = get_secret('SECRET_KEY') | ||||
| 
 | ||||
| # SECURITY WARNING: don't run with debug turned on in production! | ||||
| DEBUG = True | ||||
| DEBUG = False | ||||
| 
 | ||||
| # Quick-start development settings - unsuitable for production | ||||
| # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ | ||||
| 
 | ||||
| # SECURITY WARNING: keep the secret key used in production secret! | ||||
| # SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul' | ||||
| 
 | ||||
| # SECURITY WARNING: don't run with debug turned on in production! | ||||
| DEBUG = False | ||||
| 
 | ||||
| STATIC_ROOT = BASE_DIR / 'staticfiles' | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue