Check if database tables are ready

This commit is contained in:
Oliver Walters 2021-05-28 12:54:55 +10:00
parent 0978235370
commit 7832ccccc2

View File

@ -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}")