Django email backends and webhooks for Amazon SES, Brevo (Sendinblue), MailerSend, Mailgun, Mailjet, Postmark, Postal, Resend, SendGrid, SparkPost, Unisender Go and more
I'm trying to package anymail for Debian and experienced this issue.
I'm trying to package anymail version 10.3 and when I run tests, many of them fail with error "AppRegistryNotReady: Apps aren't loaded yet"
I' using django 4.2.13 along with it.
There were generally two kinds of stack trace which directly lead to above error
ERROR: test_warns_if_no_auth (tests.test_sparkpost_webhooks.SparkPostWebhookSecurityTestCase.test_warns_if_no_auth)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/test/utils.py", line 461, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/tests/webhook_cases.py", line 109, in test_warns_if_no_auth
response = self.call_webhook()
^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/tests/test_sparkpost_webhooks.py", line 16, in call_webhook
return self.client.post(
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/test/client.py", line 948, in post
response = super().post(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/test/client.py", line 482, in post
return self.generic(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/test/client.py", line 609, in generic
return self.request(**r)
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/test/client.py", line 886, in request
response = self.handler(environ)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/test/client.py", line 163, in __call__
self.load_middleware()
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 40, in load_middleware
middleware = import_string(middleware_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/module_loading.py", line 30, in import_string
return cached_import(module_path, class_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/module_loading.py", line 15, in cached_import
module = import_module(module_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/django/contrib/auth/middleware.py", line 3, in <module>
from django.contrib.auth.backends import RemoteUserBackend
File "/usr/lib/python3/dist-packages/django/contrib/auth/backends.py", line 4, in <module>
from django.contrib.auth.models import Permission
File "/usr/lib/python3/dist-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/usr/lib/python3/dist-packages/django/contrib/auth/base_user.py", line 57, in <module>
class AbstractBaseUser(models.Model):
File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 129, in __new__
app_config = apps.get_containing_app_config(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 138, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Another stack trace contains the above error but ends at an error related to translation
ERROR: test_force_dict (tests.test_utils.LazyCoercionTests.test_force_dict)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/anymail/utils.py", line 593, in force_non_lazy_dict
return {key: force_non_lazy_dict(value) for key, value in obj.items()}
^^^^^^^^^
AttributeError: '__proxy__' object has no attribute 'items'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py", line 215, in _add_installed_apps_translations
app_configs = reversed(apps.get_app_configs())
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 147, in get_app_configs
self.check_apps_ready()
File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 138, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/tests/test_utils.py", line 334, in test_force_dict
result = force_non_lazy_dict(
^^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/anymail/utils.py", line 593, in force_non_lazy_dict
return {key: force_non_lazy_dict(value) for key, value in obj.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/anymail/utils.py", line 593, in <dictcomp>
return {key: force_non_lazy_dict(value) for key, value in obj.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/anymail/utils.py", line 595, in force_non_lazy_dict
return force_non_lazy(obj)
^^^^^^^^^^^^^^^^^^^
File "/home/akash/Packaging/django-anymail/django-anymail/.pybuild/cpython3_3.11_anymail/build/anymail/utils.py", line 577, in force_non_lazy
return str(obj)
^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 155, in __text_cast
return func(*self.__args, **self.__kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/translation/__init__.py", line 95, in gettext
return _trans.gettext(message)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py", line 379, in gettext
_default = _default or translation(settings.LANGUAGE_CODE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py", line 292, in translation
_translations[language] = DjangoTranslation(language)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py", line 169, in __init__
self._add_installed_apps_translations()
File "/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py", line 217, in _add_installed_apps_translations
raise AppRegistryNotReady(
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
There are few more errors with same exceptions as above from different tests.
Can you please help me with these?
I'm trying to package anymail for Debian and experienced this issue.
I'm trying to package anymail version 10.3 and when I run tests, many of them fail with error "AppRegistryNotReady: Apps aren't loaded yet"
I' using django 4.2.13 along with it.
There were generally two kinds of stack trace which directly lead to above error
Another stack trace contains the above error but ends at an error related to translation
There are few more errors with same exceptions as above from different tests. Can you please help me with these?