Skip to content

Commit

Permalink
Initialize django before import in syncdb
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Nov 20, 2024
1 parent d79c45c commit 5295728
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions backend/src/xfd_django/xfd_api/tasks/run_syncdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
Expand Down

0 comments on commit 5295728

Please sign in to comment.