mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-10-30 23:39:54 +01:00 
			
		
		
		
	split settings config between development and production
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -29,7 +29,7 @@ coverage | ||||
| .idea | ||||
|  | ||||
| # Local data | ||||
| settings_local.py | ||||
| secrets.py | ||||
| *.log | ||||
|  | ||||
| # Virtualenv | ||||
|   | ||||
							
								
								
									
										11
									
								
								note_kfet/settings/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								note_kfet/settings/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| import os | ||||
|  | ||||
| from .base import * | ||||
|  | ||||
| app_stage = os.environ.get('DJANGO_APP_STAGE', 'dev') | ||||
| if app_stage == 'prod': | ||||
|     from .production import * | ||||
| else: | ||||
|     from .development import * | ||||
|  | ||||
| from .secrets import * | ||||
| @@ -8,8 +8,8 @@ import sys | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
| 
 | ||||
| # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||||
| BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||||
| PROJECT_DIR = os.path.dirname(os.path.realpath(__file__)) | ||||
| BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||||
| PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | ||||
| APPS_DIR = os.path.realpath(os.path.join(BASE_DIR, "apps")) | ||||
| sys.path.append(APPS_DIR) | ||||
| 
 | ||||
| @@ -91,16 +91,6 @@ TEMPLATES = [ | ||||
| 
 | ||||
| WSGI_APPLICATION = 'note_kfet.wsgi.application' | ||||
| 
 | ||||
| # Database | ||||
| # https://docs.djangoproject.com/en/2.2/ref/settings/#databases | ||||
| 
 | ||||
| DATABASES = { | ||||
|     'default': { | ||||
|         'ENGINE': 'django.db.backends.sqlite3', | ||||
|         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| # Password validation | ||||
| # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators | ||||
| 
 | ||||
							
								
								
									
										47
									
								
								note_kfet/settings/development.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								note_kfet/settings/development.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| ######################## | ||||
| # Development Settings # | ||||
| ######################## | ||||
| # For local dev on your machine: | ||||
| #  - Enabled by default | ||||
| #  - use sqlite as a db engine , Debug is True. | ||||
| #  - standalone mail server | ||||
| #  - and more ... | ||||
|  | ||||
|  | ||||
| # Database | ||||
| # https://docs.djangoproject.com/en/2.2/ref/settings/#databases | ||||
| from . import * | ||||
| import os | ||||
|  | ||||
| DATABASES = { | ||||
|     'default': { | ||||
|         'ENGINE': 'django.db.backends.sqlite3', | ||||
|         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||||
|     } | ||||
| } | ||||
|  | ||||
| # Break it, fix it! | ||||
| DEBUG = True | ||||
|  | ||||
| # Mandatory ! | ||||
| ALLOWED_HOSTS = ['127.0.0.1','note.comby.xyz'] | ||||
|  | ||||
| # Emails | ||||
| EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||||
| # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||||
| # EMAIL_USE_SSL = False | ||||
| # EMAIL_HOST = 'smtp.example.org' | ||||
| # EMAIL_PORT = 25 | ||||
| # EMAIL_HOST_USER = 'change_me' | ||||
| # EMAIL_HOST_PASSWORD = 'change_me' | ||||
|  | ||||
| SERVER_EMAIL = 'no-reply@example.org' | ||||
|  | ||||
| # Security settings | ||||
| SECURE_CONTENT_TYPE_NOSNIFF = False | ||||
| SECURE_BROWSER_XSS_FILTER = False | ||||
| SESSION_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_HTTPONLY = False | ||||
| X_FRAME_OPTIONS = 'DENY' | ||||
| SESSION_COOKIE_AGE = 60 * 60 * 3 | ||||
							
								
								
									
										46
									
								
								note_kfet/settings/production.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								note_kfet/settings/production.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| ######################## | ||||
| # Production  Settings # | ||||
| ######################## | ||||
| # For local dev on your machine: | ||||
| #  - Enabled by setting env variable DJANGO_APP_STAGE = 'prod' | ||||
| #  - use Postgresql as db engine | ||||
| #  - Debug should be false. | ||||
| #  - should have a dedicated mail server | ||||
| #  - and more ... | ||||
|  | ||||
| DATABASES = { | ||||
|     'default': { | ||||
|         'ENGINE': 'django.db.backends.postgresql', | ||||
|         'NAME': 'mydatabase', | ||||
|         'USER': 'mydatabaseuser', | ||||
|         'PASSWORD': 'mypassword', | ||||
|         'HOST': '127.0.0.1', | ||||
|         'PORT': '5432', | ||||
|     } | ||||
| } | ||||
|  | ||||
| # Break it, fix it! | ||||
| DEBUG = True | ||||
|  | ||||
| # Mandatory ! | ||||
| ALLOWED_HOSTS = ['127.0.0.1','note.comby.xyz'] | ||||
|  | ||||
| # Emails | ||||
| EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||||
| # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||||
| # EMAIL_USE_SSL = False | ||||
| # EMAIL_HOST = 'smtp.example.org' | ||||
| # EMAIL_PORT = 25 | ||||
| # EMAIL_HOST_USER = 'change_me' | ||||
| # EMAIL_HOST_PASSWORD = 'change_me' | ||||
|  | ||||
| SERVER_EMAIL = 'no-reply@example.org' | ||||
|  | ||||
| # Security settings | ||||
| SECURE_CONTENT_TYPE_NOSNIFF = False | ||||
| SECURE_BROWSER_XSS_FILTER = False | ||||
| SESSION_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_HTTPONLY = False | ||||
| X_FRAME_OPTIONS = 'DENY' | ||||
| SESSION_COOKIE_AGE = 60 * 60 * 3 | ||||
							
								
								
									
										2
									
								
								note_kfet/settings/secrets.py_example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								note_kfet/settings/secrets.py_example
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
|  | ||||
| SECRET_KEY = 'CHANGE_ME_IN_LOCAL_SETTINGS!' | ||||
| @@ -1,22 +0,0 @@ | ||||
| # Obligatoire, liste des host autorisés | ||||
| ALLOWED_HOSTS = ['127.0.0.1'] | ||||
|  | ||||
| # Emails | ||||
| EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||||
| # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||||
| # EMAIL_USE_SSL = False | ||||
| # EMAIL_HOST = 'smtp.example.org' | ||||
| # EMAIL_PORT = 25 | ||||
| # EMAIL_HOST_USER = 'change_me' | ||||
| # EMAIL_HOST_PASSWORD = 'change_me' | ||||
|  | ||||
| SERVER_EMAIL = 'no-reply@example.org' | ||||
|  | ||||
| # Security settings | ||||
| SECURE_CONTENT_TYPE_NOSNIFF = False | ||||
| SECURE_BROWSER_XSS_FILTER = False | ||||
| SESSION_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_SECURE = False | ||||
| CSRF_COOKIE_HTTPONLY = False | ||||
| X_FRAME_OPTIONS = 'DENY' | ||||
| SESSION_COOKIE_AGE = 60 * 60 * 3 | ||||
| @@ -23,5 +23,4 @@ chmod-socket    = 664 | ||||
| # clear environment on exit | ||||
| vacuum          = true | ||||
| #Touch reload | ||||
| touch-reload = /var/www/note_kfet/note_kfet/settings.py | ||||
|  | ||||
| touch-reload = /var/www/note_kfet/note_kfet/settings/__init__.py | ||||
|   | ||||
		Reference in New Issue
	
	Block a user