Skip to content

Commit

Permalink
Move django.setup before import
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Nov 20, 2024
1 parent f46b571 commit b101bb1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions backend/src/xfd_django/xfd_api/tasks/run_syncdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

# Third-Party Libraries
import django

# 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 django.core.management import call_command
from xfd_api.management.commands.syncdb import (
populate_sample_data,
Expand All @@ -14,12 +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)
Expand Down

0 comments on commit b101bb1

Please sign in to comment.