Skip to content

Commit de85b54

Browse files
committed
ok
1 parent 6259ab5 commit de85b54

18 files changed

+27
-152
lines changed

db.sqlite3

0 Bytes
Binary file not shown.
-12 Bytes
Binary file not shown.
-2.32 KB
Binary file not shown.
0 Bytes
Binary file not shown.
-12 Bytes
Binary file not shown.

ons_trading/settings.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import os
1414
from pathlib import Path
15+
import dj_database_url # Import dj_database_url
1516

1617
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1718
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -21,12 +22,18 @@
2122
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
2223

2324
# SECURITY WARNING: keep the secret key used in production secret!
24-
SECRET_KEY = "django-insecure-n&a6vut67vp5ysh09jvsts&6%m5e*b_#hr82iuw(1dk^d18yok"
25+
# Get the SECRET_KEY from a Render environment variable
26+
SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-n&a6vut67vp5ysh09jvsts&6%m5e*b_#hr82iuw(1dk^d18yok')
2527

2628
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = True
29+
# Get DEBUG status from a Render environment variable (defaults to False)
30+
DEBUG = os.environ.get('DEBUG', 'False') == 'True'
2831

32+
# Get the ALLOWED_HOSTS from Render's environment variable
2933
ALLOWED_HOSTS = []
34+
RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME')
35+
if RENDER_EXTERNAL_HOSTNAME:
36+
ALLOWED_HOSTS.append(RENDER_EXTERNAL_HOSTNAME)
3037

3138

3239
# Application definition
@@ -43,6 +50,8 @@
4350

4451
MIDDLEWARE = [
4552
"django.middleware.security.SecurityMiddleware",
53+
# Add WhiteNoise middleware right after SecurityMiddleware
54+
'whitenoise.middleware.WhiteNoiseMiddleware',
4655
"django.contrib.sessions.middleware.SessionMiddleware",
4756
"django.middleware.common.CommonMiddleware",
4857
"django.middleware.csrf.CsrfViewMiddleware",
@@ -75,18 +84,20 @@
7584
# Database
7685
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
7786

87+
# This setup uses dj_database_url to read the DATABASE_URL env var from Render
7888
DATABASES = {
79-
'default': {
80-
'ENGINE': 'django.db.backends.sqlite3',
81-
'NAME': BASE_DIR / "db.sqlite3",
82-
}
89+
'default': dj_database_url.config(
90+
# Use SQLite locally if DATABASE_URL is not set
91+
default=f'sqlite:///{BASE_DIR / "db.sqlite3"}',
92+
conn_max_age=600,
93+
)
8394
}
8495

8596

8697
# Password validation
8798
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
8899

89-
AUTH_PASSWORD_VALIDATORS = [
100+
AUTH_PASSWORD_validators = [
90101
{
91102
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
92103
},
@@ -109,7 +120,7 @@
109120

110121
TIME_ZONE = 'Asia/Kolkata'
111122

112-
USE_I18N = True
123+
USE_I1N = True
113124

114125
USE_TZ = True
115126

@@ -119,7 +130,14 @@
119130

120131
STATIC_URL = "static/"
121132

133+
# This is the directory where collectstatic will gather all static files.
134+
STATIC_ROOT = BASE_DIR / 'staticfiles'
135+
136+
# Enable WhiteNoise to serve static files efficiently.
137+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
138+
139+
122140
# Default primary key field type
123141
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
124142

125-
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
143+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
-12 Bytes
Binary file not shown.
-12 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)