catch db not loaded

This commit is contained in:
Matthias 2021-10-19 20:59:14 +02:00
parent 23558e235b
commit f86bd4dd6b
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -5,6 +5,7 @@ from typing import OrderedDict
from django.apps import AppConfig, apps from django.apps import AppConfig, apps
from django.conf import settings from django.conf import settings
from django.db.utils import OperationalError, ProgrammingError
class PluginConfig(AppConfig): class PluginConfig(AppConfig):
@ -14,6 +15,7 @@ class PluginConfig(AppConfig):
from common.models import InvenTreeSetting from common.models import InvenTreeSetting
plugins = settings.INTEGRATION_PLUGINS.items() plugins = settings.INTEGRATION_PLUGINS.items()
try:
# if plugin settings are enabled enhance the settings # if plugin settings are enabled enhance the settings
if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'): if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'):
for slug, plugin in plugins: for slug, plugin in plugins:
@ -44,3 +46,6 @@ class PluginConfig(AppConfig):
apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
apps.clear_cache() apps.clear_cache()
apps.populate(settings.INSTALLED_APPS) apps.populate(settings.INSTALLED_APPS)
except (OperationalError, ProgrammingError):
# Exception if the database has not been migrated yet
pass