File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11DJANGO_SETTINGS_MODULE = {{project_name}}.settings.local
2- # Label shown in the Django admin header to make the active environment explicit.
3- ADMIN_ENVIRONMENT_LABEL = Local
4- ADMIN_ENVIRONMENT_COLOR = #111827
5- ADMIN_ENVIRONMENT_BACKGROUND_COLOR = #f59e0b
62CELERY_BROKER_URL = amqp://broker:5672//
73REDIS_URL = redis://result:6379
84# Please choose postgres or sqlite as your DB:
95# DATABASE_URL=postgres://{{project_name}}:password@db:5432/{{project_name}}
106# DATABASE_URL=sqlite:///db.sqlite3
7+
8+ # # Label shown in the Django admin header to make the active environment explicit.
9+ ADMIN_ENVIRONMENT_LABEL = Local
10+ ADMIN_ENVIRONMENT_COLOR = #111827
11+ ADMIN_ENVIRONMENT_BACKGROUND_COLOR = #f59e0b
Original file line number Diff line number Diff line change 1+ import logging
12import os
23
34from django .conf import settings
45
56
7+ logger = logging .getLogger (__name__ )
8+
9+
610def _default_admin_environment_label ():
711 settings_module = getattr (settings , "SETTINGS_MODULE" , "" ) or os .getenv (
812 "DJANGO_SETTINGS_MODULE" , ""
913 )
1014 if settings_module :
11- return settings_module .rsplit ("." , maxsplit = 1 )[- 1 ].replace ("_" , " " ).title ()
15+ try :
16+ environment_label = (
17+ settings_module .rsplit ("." , maxsplit = 1 )[- 1 ].replace ("_" , " " ).title ()
18+ )
19+ if not environment_label :
20+ raise IndexError
21+ return environment_label
22+ except IndexError :
23+ logger .warning (
24+ "Could not determine admin environment label from SETTINGS_MODULE: %s" ,
25+ settings_module ,
26+ )
27+ return "Unknown"
1228
1329 return "Local"
1430
Original file line number Diff line number Diff line change @@ -182,11 +182,6 @@ def base_dir_join(*args):
182182# Sentry
183183SENTRY_DSN = config ("SENTRY_DSN" , default = "" )
184184COMMIT_SHA = config ("RENDER_GIT_COMMIT" , default = "" )
185- ADMIN_ENVIRONMENT_LABEL = config ("ADMIN_ENVIRONMENT_LABEL" , default = "" )
186- ADMIN_ENVIRONMENT_COLOR = config ("ADMIN_ENVIRONMENT_COLOR" , default = "#111827" )
187- ADMIN_ENVIRONMENT_BACKGROUND_COLOR = config (
188- "ADMIN_ENVIRONMENT_BACKGROUND_COLOR" , default = "#f59e0b"
189- )
190185
191186# Fix for Safari 12 compatibility issues, please check:
192187# https://github.com/vintasoftware/safari-samesite-cookie-issue
@@ -257,3 +252,8 @@ def base_dir_join(*args):
257252DEFENDER_COOLOFF_TIME = 300 # 5 minutes
258253DEFENDER_LOCKOUT_TEMPLATE = "defender/lockout.html"
259254DEFENDER_REDIS_URL = config ("REDIS_URL" )
255+
256+ # Admin Env Label"
257+ ADMIN_ENVIRONMENT_LABEL = config ("ADMIN_ENVIRONMENT_LABEL" , default = "" )
258+ ADMIN_ENVIRONMENT_COLOR = config ("ADMIN_ENVIRONMENT_COLOR" , default = "#111827" )
259+ ADMIN_ENVIRONMENT_BACKGROUND_COLOR = config ("ADMIN_ENVIRONMENT_BACKGROUND_COLOR" , default = "#f59e0b" )
Original file line number Diff line number Diff line change 135135
136136# Sentry
137137sentry_sdk .init (dsn = SENTRY_DSN , integrations = [DjangoIntegration ()], release = COMMIT_SHA )
138+
139+ # Admin Env Label
138140ADMIN_ENVIRONMENT_LABEL = config ("ADMIN_ENVIRONMENT_LABEL" , default = "" )
139141ADMIN_ENVIRONMENT_COLOR = config ("ADMIN_ENVIRONMENT_COLOR" , default = "white" )
140142ADMIN_ENVIRONMENT_BACKGROUND_COLOR = config ("ADMIN_ENVIRONMENT_BACKGROUND_COLOR" , default = "red" )
You can’t perform that action at this time.
0 commit comments