diff --git a/backend/src/xfd_django/xfd_api/tasks/run_syncdb.py b/backend/src/xfd_django/xfd_api/tasks/run_syncdb.py index 88c4279b..79dae249 100644 --- a/backend/src/xfd_django/xfd_api/tasks/run_syncdb.py +++ b/backend/src/xfd_django/xfd_api/tasks/run_syncdb.py @@ -7,7 +7,13 @@ from django.db import migrations, connection from django.db.migrations.executor import MigrationExecutor -# Custom Utilities +# Set the Django settings module +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xfd_django.settings") +os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true" + +# Initialize Django +django.setup() + from xfd_api.tasks.syndb_helpers import manage_elasticsearch_indices, populate_sample_data @@ -16,13 +22,6 @@ def handler(event, context): Lambda handler to trigger syncdb. """ - # Set the Django settings module - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xfd_django.settings") - os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true" - - # Initialize Django - django.setup() - # Parse arguments from the event dangerouslyforce = event.get("dangerouslyforce", False) populate = event.get("populate", False)