Explorar el Código

switch db to postgres

Prach Pongpanich %!s(int64=2) %!d(string=hace) años
padre
commit
274e984a3a
Se han modificado 1 ficheros con 13 adiciones y 3 borrados
  1. 13 3
      app/tmt_learning/settings.py

+ 13 - 3
app/tmt_learning/settings.py

@@ -11,10 +11,15 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
11 11
 """
12 12
 
13 13
 from pathlib import Path
14
+import os
15
+import environ
14 16
 
15 17
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 18
 BASE_DIR = Path(__file__).resolve().parent.parent
17 19
 
20
+env = environ.Env()
21
+environ.Env.read_env()
22
+
18 23
 
19 24
 # Quick-start development settings - unsuitable for production
20 25
 # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
@@ -25,7 +30,7 @@ SECRET_KEY = 'django-insecure-=itdty(p8!f1rbdmhh5+*7n%98ks8oh)l0x6%5!j7_c_&7o+gt
25 30
 # SECURITY WARNING: don't run with debug turned on in production!
26 31
 DEBUG = True
27 32
 
28
-ALLOWED_HOSTS = []
33
+ALLOWED_HOSTS = ['*']
29 34
 
30 35
 
31 36
 # Application definition
@@ -75,12 +80,17 @@ WSGI_APPLICATION = 'tmt_learning.wsgi.application'
75 80
 
76 81
 DATABASES = {
77 82
     'default': {
78
-        'ENGINE': 'django.db.backends.sqlite3',
79
-        'NAME': BASE_DIR / 'db.sqlite3',
83
+        'ENGINE': 'django.db.backends.postgresql_psycopg2',
84
+        'NAME': env("POSTGRES_NAME"),
85
+        'USER': env("POSTGRES_USER"),
86
+        'PASSWORD': env("POSTGRES_PASSWORD"),
87
+        'HOST': 'db',
88
+        'PORT': '5432',
80 89
     }
81 90
 }
82 91
 
83 92
 
93
+
84 94
 # Password validation
85 95
 # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
86 96