mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Check if database tables are ready
This commit is contained in:
parent
0978235370
commit
7832ccccc2
@ -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}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user