Skip to content

_db_compat.setup_db_compat() should probably be called in iommi.apps.AppConfig.ready #671

@berycz

Description

@berycz

I ran to it when adding SortOrderField into models.py, where I also had an abstract model
so when I did from iommi.models import SortOrderField in setup_db_compat, I got

  File "iommi/iommi/__init__.py", line 58, in <module>
    setup_db_compat()
  File "iommi/iommi/_db_compat.py", line 7, in setup_db_compat
    setup_db_compat_iommi()
  File "iommi/iommi/_db_compat.py", line 173, in setup_db_compat_iommi
    from iommi.models import SortOrderField
  File "iommi/iommi/models.py", line 17, in <module>
    class Orderable(models.Model):
  File "iommi/venv/lib/python3.12/site-packages/django/db/models/base.py", line 129, in __new__
    app_config = apps.get_containing_app_config(module)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "iommi/venv/lib/python3.12/site-packages/django/apps/registry.py", line 260, in get_containing_app_config
    self.check_apps_ready()
  File "iommi/venv/lib/python3.12/site-packages/django/apps/registry.py", line 138, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")

that's why I put the field in model_fields.py, but if it was called in app ready, we wouldn't have that problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions