Skip to content

Commit

Permalink
feat: by default make all fields a link
Browse files Browse the repository at this point in the history
  • Loading branch information
iosifnicolae2 authored Sep 25, 2024
1 parent 3f652ba commit 87afadd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(**{
Expand All @@ -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'
)
}
Expand Down

0 comments on commit 87afadd

Please sign in to comment.