from django.apps import AppConfig class TournamentsConfig(AppConfig): name = 'tournaments' default_auto_field = 'django.db.models.BigAutoField' def ready(self): import tournaments.signals # This will ensure the signals are registered # Start background tasks in production # Schedule background tasks on startup from django.conf import settings if not settings.DEBUG: # Only in production try: from background_task.models import Task from tournaments.tasks import check_confirmation_deadlines # Clear existing tasks first to avoid duplicates Task.objects.filter(task_name='tournaments.tasks.check_confirmation_deadlines').delete() # Schedule the task to run every 30 minutes (1800 seconds) check_confirmation_deadlines(repeat=1800) except: # Handle exceptions during startup pass