Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Easy
Description
Currently in settings.py all output view providers are instantiated. However, they might import code that transitively imports Django models which is not allowed in Django until all apps have been loaded (see https://docs.djangoproject.com/en/3.2/ref/applications/#initialization-process). A better approach would be to instantiate the output view providers in the ApiConfig.ready().
File "/Users/machrist/Airavata/django/django_airavata_gateway/django_airavata/settings.py", line 644, in <module> OUTPUT_VIEW_PROVIDERS[entry_point.name] = entry_point.load()() File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2517, in load return self.resolve() File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2523, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/Users/machrist/Airavata/django/regsnp-django-app/regsnp_django_app/output_views.py", line 32, in <module> from airavata_django_portal_sdk import urls File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/airavata_django_portal_sdk/urls.py", line 6, in <module> from . import views File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/airavata_django_portal_sdk/views.py", line 16, in <module> from rest_framework.decorators import api_view File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/decorators.py", line 13, in <module> from rest_framework.views import APIView File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/views.py", line 17, in <module> from rest_framework.schemas import DefaultSchema File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/schemas/__init__.py", line 33, in <module> authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/settings.py", line 225, in __getattr__ val = perform_import(val, attr) File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/settings.py", line 168, in perform_import return [import_from_string(item, setting_name) for item in val] File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/settings.py", line 168, in <listcomp> return [import_from_string(item, setting_name) for item in val] File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/rest_framework/settings.py", line 177, in import_from_string return import_string(val) File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/Users/machrist/Airavata/django/django_airavata_gateway/django_airavata/apps/api/authentication.py", line 6, in <module> from django_airavata.apps.auth import utils File "/Users/machrist/Airavata/django/django_airavata_gateway/django_airavata/apps/auth/utils.py", line 14, in <module> from . import models File "/Users/machrist/Airavata/django/django_airavata_gateway/django_airavata/apps/auth/models.py", line 17, in <module> class EmailVerification(models.Model): File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/django/db/models/base.py", line 108, in __new__ app_config = apps.get_containing_app_config(module) File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/django/apps/registry.py", line 253, in get_containing_app_config self.check_apps_ready() File "/Users/machrist/Airavata/django/django_airavata_gateway/venv/lib/python3.10/site-packages/django/apps/registry.py", line 136, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.