mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Catch exception where InvenTree setting object is referenced but the database is not migrated yet
This commit is contained in:
parent
cb3c86f87a
commit
0988040172
@ -16,6 +16,7 @@ from djmoney.models.fields import MoneyField
|
|||||||
from djmoney.contrib.exchange.models import convert_money
|
from djmoney.contrib.exchange.models import convert_money
|
||||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||||
|
|
||||||
|
from django.db.utils import OperationalError
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
@ -280,12 +281,20 @@ class InvenTreeSetting(models.Model):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
setting = InvenTreeSetting.objects.filter(key__iexact=key).first()
|
setting = InvenTreeSetting.objects.filter(key__iexact=key).first()
|
||||||
except (InvenTreeSetting.DoesNotExist):
|
except OperationalError:
|
||||||
# Create the setting if it does not exist
|
# Settings table has not been created yet!
|
||||||
|
return None
|
||||||
|
except (ValueError, InvenTreeSetting.DoesNotExist):
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Attempt Create the setting if it does not exist
|
||||||
setting = InvenTreeSetting.create(
|
setting = InvenTreeSetting.create(
|
||||||
key=key,
|
key=key,
|
||||||
value=InvenTreeSetting.get_default_value(key)
|
value=InvenTreeSetting.get_default_value(key)
|
||||||
)
|
)
|
||||||
|
except OperationalError:
|
||||||
|
# Settings table has not been created yet
|
||||||
|
setting = None
|
||||||
|
|
||||||
return setting
|
return setting
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user