se agrega variables de entorno en conexion de database

francisco/prueba1
Francisco Sandoval 2023-06-03 17:45:00 -04:00
parent 4f614678be
commit caa64562b8
8 changed files with 18 additions and 8 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
.env
.vscode
__pycache__

View File

@ -13,6 +13,13 @@ services:
ports:
- 4000:8000
command: sh /start.sh
environment:
DBHOST: db
DBPORT: 5432
DBNAME: database
DBUSER: postgres
DBPASS: password
DBSCHEMA: desarrollo1
db:
image: postgres:14-alpine

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from pathlib import Path
from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -79,13 +80,13 @@ WSGI_APPLICATION = 'project.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': 'db',
'PORT': 5432,
'USER': 'postgres',
'PASSWORD': 'password',
'NAME': 'database',
'HOST': config('DBHOST', 'localhost'),
'PORT': config('DBPORT', 5432),
'USER': config('DBUSER','postgres'),
'PASSWORD': config('DBPASS','password'),
'NAME': config('DBNAME','database'),
'OPTIONS': {
'options': '-c search_path=desarrollo1'
'options': '-c search_path=' + config('DBSCHEMA', 'public')
}
}
}

View File

@ -2,3 +2,4 @@ django
psycopg2-binary
djangorestframework
coreapi
python-decouple