diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 994a344cc9..d45df99152 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -168,7 +168,7 @@ def update_exchange_rates(): try: from InvenTree.exchange import InvenTreeExchange - from djmoney.contrib.exchange.models import Rate + from djmoney.contrib.exchange.models import ExchangeBackend, Rate from django.conf import settings except AppRegistryNotReady: # Apps not yet loaded! @@ -177,6 +177,16 @@ def update_exchange_rates(): # Other error? return + # Test to see if the database is ready yet + try: + backend = ExchangeBackend.objects.get(name='InvenTreeExchange') + except ExchangeBackend.DoesNotExist: + pass + except: + # Some other error + print("Database not ready") + return + backend = InvenTreeExchange() print(f"Updating exchange rates from {backend.url}")