Skip to content

Commit

Permalink
fix: Do not initialize REGISTERED_ADMINS with model setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 4, 2024
1 parent 929fc88 commit 9c7d0de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion djangocms_link/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class GrouperModelAdmin:
pass

REGISTERED_ADMIN = getattr(settings, "DJANGOCMS_LINKABLE_MODELS", "auto")
REGISTERED_ADMIN = [] # Will be set by djangocms_link.apps.DjangoCmsLinkConfig.ready


class AdminUrlsView(BaseListView):
Expand Down
7 changes: 5 additions & 2 deletions djangocms_link/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.apps import AppConfig, apps
from django.conf import settings
from django.contrib.admin import ModelAdmin
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import gettext_lazy as _
Expand All @@ -14,7 +15,9 @@ def ready(self):

from djangocms_link import admin as link_admin

if link_admin.REGISTERED_ADMIN == "auto": # pragma: no cover
link_model_setting = getattr(settings, "DJANGOCMS_LINKABLE_MODELS", "auto")

if link_model_setting == "auto": # pragma: no cover
# Autoconfig? Check the admin registry for suitable admins
link_admin.REGISTERED_ADMIN = []
for _admin in admin.site._registry.values():
Expand All @@ -28,7 +31,7 @@ def ready(self):
else:
# turn model config into model admin instances
admins = []
for model in link_admin.REGISTERED_ADMIN:
for model in link_model_setting:
if isinstance(model, str):
model = apps.get_model(model)
if not hasattr(model, "get_absolute_url"): # pragma: no cover
Expand Down

0 comments on commit 9c7d0de

Please sign in to comment.