Skip to content

Commit

Permalink
fix(cfg): config fixes
Browse files Browse the repository at this point in the history
fix(cfg): idiot's config construction

fix(cfg): typo in env variable XD

fix(cfg): url parse stuff left a slash

fix(cfg): prod reconfig according rest deployment?!

fix(cfg): debug in prod confirmed??!!?

fix(cfg): env forced?? note to myself pls squash this
  • Loading branch information
hUwUtao committed May 26, 2024
1 parent f0b8435 commit c22fce9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 3 additions & 4 deletions fuhoblog/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)

SECRET_KEY = os.environ["SECRET_KEY"] or ""
SECRET_KEY = os.environ['SECRET_KEY'] or ''

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
Expand All @@ -41,6 +41,7 @@
'wagtail_localize',
'wagtail_localize.locales',
# API engine
'rest_framework',
'wagtail.api.v2',
# Whatever
'wagtail.contrib.forms',
Expand Down Expand Up @@ -190,6 +191,4 @@

# Base URL to use when referring to full URLs within the Wagtail admin backend -
# e.g. in notification emails. Don't include '/admin' or a trailing slash
WAGTAILADMIN_BASE_URL = 'http://example.com'

CSRF_COOKIE_SECURE = True
WAGTAILADMIN_BASE_URL = 'http://example.com'
2 changes: 1 addition & 1 deletion fuhoblog/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

INSTALLED_APPS += ['rest_framework']
INSTALLED_APPS += []

try:
from .local import *
Expand Down
16 changes: 9 additions & 7 deletions fuhoblog/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import os
from urllib.parse import urlparse

DEBUG = False
DEBUG = False or (
os.environ['DJANGO_DEBUG'] is not None and os.environ['DJANGO_DEBUG'] == 'True'
)

if SECRET_KEY == '':
print('no SECRET_KEY env')
Expand All @@ -14,16 +16,16 @@

if os.environ.get('DATABASE') is not None:
try:
DATABASE_ENVIRON = urlparse(os.environ['DASTABASE'])
DATABASE_ENVIRON = urlparse(os.environ['DATABASE'])
if DATABASE_ENVIRON.scheme == 'mysql':
DATABASES |= {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['MYSQL_DATABASE'],
'USER': os.environ['MYSQL_PASSWORD'],
'PASSWORD': os.environ['MYSQL_PASSWORD'],
'HOST': os.environ['MYSQL_HOST'],
'PORT': os.environ['MYSQL_PORT'],
'NAME': DATABASE_ENVIRON.path.replace('/', '') or 'wagtail',
'USER': DATABASE_ENVIRON.username or 'root',
'PASSWORD': DATABASE_ENVIRON.password or '',
'HOST': DATABASE_ENVIRON.hostname or 'localhost',
'PORT': int(DATABASE_ENVIRON.port) or 3306,
},
}
else:
Expand Down

0 comments on commit c22fce9

Please sign in to comment.