diff --git a/backend/app/management/commands/compile_translations.py b/backend/app/management/commands/compile_translations.py index d19c3888..84acd632 100644 --- a/backend/app/management/commands/compile_translations.py +++ b/backend/app/management/commands/compile_translations.py @@ -37,7 +37,8 @@ def translate(fro, to, src_dir, dest_dir, fuzzy=False): # due to conflict with Django BaseCommand parser class Arguments: def __init__(self, **kwargs): - [setattr(self, attr, val) for attr, val in kwargs.items()] + for attr, val in kwargs.items(): + setattr(self, attr, val) arguments = Arguments(fro=fro, to=to, src=src_dir, dest=dest_dir) diff --git a/backend/app/management/commands/runanalysis.py b/backend/app/management/commands/runanalysis.py index 66a66945..c4e68ce6 100644 --- a/backend/app/management/commands/runanalysis.py +++ b/backend/app/management/commands/runanalysis.py @@ -120,4 +120,3 @@ def handle(self, *args, **options): photos_done += 1 if photos_done % 25 == 0: print(f'\nAnalyzed {photos_done} so far...') - diff --git a/backend/config/settings/base.py b/backend/config/settings/base.py index 324c176b..207f5930 100644 --- a/backend/config/settings/base.py +++ b/backend/config/settings/base.py @@ -17,7 +17,7 @@ CONFIG_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BACKEND_DIR = os.path.dirname(CONFIG_DIR) PROJECT_ROOT = os.path.dirname(BACKEND_DIR) -MIGRATIONS_DIR = os.path.join(os.path.dirname(CONFIG_DIR), 'app/migrations') +MIGRATIONS_DIR = os.path.join(os.path.dirname(CONFIG_DIR), 'app', 'migrations') SETTINGS_DIR = os.path.join(CONFIG_DIR, 'settings') BACKEND_DATA_DIR = os.path.join(BACKEND_DIR, 'data') @@ -46,6 +46,7 @@ # We used to use this directory as a fallback in development for _showing_ images # as well, but we no longer do this: all image display is via the S3 bucket. LOCAL_PHOTOS_DIR = None +LOCAL_DB_PATH = os.path.join(BACKEND_DIR, 'db.sqlite3') BLOG_ROOT_URL = "articles" @@ -128,19 +129,24 @@ # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases +db_config = { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': LOCAL_DB_PATH, +} pw_path = Path(PROJECT_ROOT, 'db_password.txt') -with open(pw_path, 'r', encoding='utf-8') as pw_file: - db_pw = pw_file.readline().strip() - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'HOST': 'paris1970-urop-fa22.crdpmszp71qh.us-east-1.rds.amazonaws.com', - 'USER': 'urop', - 'NAME': 'paris1970-urop-fa22', - 'PORT': '5432', - 'PASSWORD': db_pw, +if os.path.exists(pw_path): + with open(pw_path, 'r', encoding='utf-8') as pw_file: + db_pw = pw_file.readline().strip() + db_config = { + 'ENGINE': 'django.db.backends.postgresql', + 'HOST': 'paris1970-urop-fa22.crdpmszp71qh.us-east-1.rds.amazonaws.com', + 'USER': 'urop', + 'NAME': 'paris1970-urop-fa22', + 'PORT': '5432', + 'PASSWORD': db_pw, } +DATABASES = { + 'default': db_config }