Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gnthibault committed Nov 22, 2024
1 parent dc01193 commit 1d01cc5
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions mytom/mytom/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'qmy$h3u(+r@!zcbuxc&s6)4i8l_9and&fxcz069&60ny^!1p*^'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['*']
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
# CSRF_TRUSTED_ORIGINS = ['http://*', 'https://*']
Expand Down Expand Up @@ -186,15 +183,17 @@
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
}
},
'loggers': {
'': {
'': { # Root logger
'handlers': ['console'],
'level': 'INFO'
'level': 'DEBUG',
}
}
}
logging.config.dictConfig(LOGGING)

# Caching
# https://docs.djangoproject.com/en/dev/topics/cache/#filesystem-caching
Expand All @@ -208,10 +207,18 @@

# SECURITY WARNING: don't run with debug turned on in production!
# Change this to "False" when you are ready for production
env = environ.Env(DEBUG=(bool, False))
env = environ.Env(
# set casting, default value
DEBUG=(bool, True)
)
DEBUG = env('DEBUG')
env_file = os.path.join(BASE_DIR, ".env")
logger = logging.getLogger(__name__)
logger.error(f'XXXXXXXXXXXXXXX')
if DEBUG:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)

# Attempt to load the Project ID into the environment, safely failing on error.
try:
_, os.environ["GOOGLE_CLOUD_PROJECT"] = google.auth.default()
Expand All @@ -228,7 +235,7 @@
name = f"projects/{project_id}/secrets/{settings_name}/versions/latest"
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
env.read_env(io.StringIO(payload))
logger.error(f'env is {env}')
logger.debug(f'env is {env}')
else:
raise Exception("No local .env or GOOGLE_CLOUD_PROJECT detected. No secrets found.")

Expand All @@ -238,7 +245,7 @@
if os.getenv("USE_CLOUD_SQL_AUTH_PROXY", None):
DATABASES["default"]["HOST"] = "127.0.0.1"
DATABASES["default"]["PORT"] = 5432
logger.error(f'Database is {DATABASES}')
logger.debug(f'Database is {DATABASES}')
# django.db.connection.ensure_connection()

GS_BUCKET_NAME = env("GS_BUCKET_NAME")
Expand Down

0 comments on commit 1d01cc5

Please sign in to comment.