From 87afadd26d50c89ca1a384861f9333979be10f34 Mon Sep 17 00:00:00 2001 From: Iosif Nicolae Date: Wed, 25 Sep 2024 13:12:13 +0300 Subject: [PATCH] feat: by default make all fields a link --- helpers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/helpers.py b/helpers.py index 1009e5b..5ac9a7e 100644 --- a/helpers.py +++ b/helpers.py @@ -33,7 +33,7 @@ def is_custom_html_field(self) -> bool: ) try: - f, attr, value = lookup_field(field, obj, model_admin) + f, attr, config = lookup_field(field, obj, model_admin) except (AttributeError, ValueError, ObjectDoesNotExist): return False @@ -79,6 +79,9 @@ def get_readonly_fields(self, request, obj=None): return tuple(readonly_fields) + tuple(custom_html_fields) + def get_list_display_links(self, request, list_display): + return self.list_display + def get_actions_hidden(self, request: HttpRequest) -> List[UnfoldAction]: return self._filter_unfold_actions_by_permissions( request, self._get_base_actions_hidden() @@ -160,8 +163,8 @@ def clean(self): if isinstance(field, ChainedForeignKey): computed_filters = {} if field.dynamic_filters: - for key, value in field.filters.items(): - computed_filters[key] = getattr(self, value).pk or None + for key, config in field.filters.items(): + computed_filters[key] = getattr(self, config).pk or None else: computed_filters = field.filters if not field.remote_field.model.objects.filter(**{ @@ -171,7 +174,7 @@ def clean(self): raise ValidationError( { field.name: ValidationError( - f"Invalid value for {field.name}", + f"Invalid config for {field.name}", code='invalid' ) }