Skip to content

Commit

Permalink
adds postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Oct 2, 2024
1 parent 54f7818 commit a0d61f1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
12 changes: 11 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
export CLOUND_NAME=
export CLOUD_API_KEY=
export CLOUD_API_SECRET=
export CLOUD_API_SECRET=

DEBUG=True
USE_POSTGRES=False

# PostgreSQL settings
POSTGRES_DB=your_database_name
POSTGRES_USER=your_database_user
POSTGRES_PASSWORD=your_database_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
15 changes: 13 additions & 2 deletions alloexpertsbackend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SECRET_KEY = 'django-insecure-svz0_*_q=m45w(i$$oaka2j92r6pmr58uir7ko&)7fv@+$i+0g'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.getenv('DEBUG', 'True') == 'True'

ALLOWED_HOSTS = ['34.207.159.186','api.allo.expert', 'ec2-34-207-159-186.compute-1.amazonaws.com', 'localhost', '127.0.0.1', '0.0.0.0']

Expand Down Expand Up @@ -86,13 +86,24 @@
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

# Database configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

if USE_POSTGRES:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': config('POSTGRES_DB'),
'USER': config('POSTGRES_USER'),
'PASSWORD': config('POSTGRES_PASSWORD'),
'HOST': config('POSTGRES_HOST', default='localhost'),
'PORT': config('POSTGRES_PORT', default='5432'),
}
}

# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ six==1.16.0
sqlparse==0.5.0
tzdata==2024.1
urllib3==2.2.3

python-decouple
psycopg2

0 comments on commit a0d61f1

Please sign in to comment.