Skip to content

Commit 434c9fa

Browse files
committed
Update for Render DEPLOY
1 parent 1d4abfa commit 434c9fa

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# exit on error
3+
set -o errexit
4+
5+
pip install --upgrade pip
6+
pip install -r requirements.txt
7+
8+
python manage.py migrate

core/settings.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,33 @@
1010
https://docs.djangoproject.com/en/3.2/ref/settings/
1111
"""
1212

13-
import os
13+
import os, environ
1414
from pathlib import Path
1515

16+
env = environ.Env(
17+
# set casting, default value
18+
DEBUG=(bool, False)
19+
)
20+
1621
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1722
BASE_DIR = Path(__file__).resolve().parent.parent
1823

1924
# Quick-start development settings - unsuitable for production
2025
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
2126

2227
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = os.getenv(
24-
"SECRET_KEY", "django-insecure-97s)x3c8w8h_qv3t3s7%)#k@dpk2edr0ed_(rq9y(rbb&_!ai%"
25-
)
28+
SECRET_KEY = env('SECRET_KEY', default='insecure-S#perS3crEt_007')
2629

2730
# SECURITY WARNING: don't run with debug turned on in production!
28-
DEBUG = False
31+
DEBUG = False
2932

3033
try:
3134
# expects 1 or 0
32-
DEBUG = int(os.environ.get("DEBUG", default=1))
35+
DEBUG = int(os.environ.get("DEBUG", default=0))
3336
except:
3437
DEBUG = False
3538

36-
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "*").split(" ")
39+
ALLOWED_HOSTS = env("DJANGO_ALLOWED_HOSTS", default="*").split(" ")
3740

3841
# Application definition
3942

@@ -87,12 +90,12 @@
8790

8891
DATABASES = {
8992
"default": {
90-
"ENGINE": os.environ.get("DB_ENGINE", "django.db.backends.sqlite3"),
91-
"NAME": os.environ.get("DB_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
92-
"USER": os.environ.get("DB_USER"),
93-
"PASSWORD": os.environ.get("DB_PASSWORD"),
94-
"HOST": os.environ.get("DB_HOST"),
95-
"PORT": os.environ.get("DB_PORT"),
93+
"ENGINE" : env("DB_ENGINE" , default="django.db.backends.sqlite3"),
94+
"NAME" : env("DB_DATABASE", default=os.path.join(BASE_DIR, "db.sqlite3")),
95+
"USER" : env("DB_USER" , default=None),
96+
"PASSWORD": env("DB_PASSWORD", default=None),
97+
"HOST" : env("DB_HOST" , default=None),
98+
"PORT" : env("DB_PORT" , default=None),
9699
}
97100
}
98101

@@ -137,6 +140,7 @@
137140

138141
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
139142

143+
# Custom user Model
140144
AUTH_USER_MODEL = "api_user.User"
141145

142146
# ##################################################################### #
@@ -151,13 +155,23 @@
151155
}
152156

153157
# ##################################################################### #
154-
# ################### CORS ############################### #
158+
# CORS
155159
# ##################################################################### #
156160

161+
CORS_ALLOW_ALL_ORIGINS=True
162+
163+
# Load the default ones
157164
CORS_ALLOWED_ORIGINS = ["http://localhost:3000", "http://127.0.0.1:3000"]
158165

166+
# Leaded from Environment
167+
CORS_ALLOWED_ORIGINS_ENV = env("CORS_ALLOWED_ORIGINS", default=None)
168+
169+
if CORS_ALLOWED_ORIGINS_ENV:
170+
CORS_ALLOWED_ORIGINS += CORS_ALLOWED_ORIGINS_ENV.split(' ')
171+
172+
159173
# ##################################################################### #
160-
# ################### TESTING ############################### #
174+
# TESTING
161175
# ##################################################################### #
162176

163177
TESTING = False

0 commit comments

Comments
 (0)