From 2e2f5fedf5b4494b010fbbf8d58b73702f85869a Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Mon, 16 Oct 2023 11:19:05 +0200 Subject: [PATCH] fix: use value from model_to_dict instead of getattr This gives us a more meaningful represeantaion of the value --- apis_core/apis_entities/detail_generic.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/apis_core/apis_entities/detail_generic.py b/apis_core/apis_entities/detail_generic.py index e10c9aa8c..922d8af60 100644 --- a/apis_core/apis_entities/detail_generic.py +++ b/apis_core/apis_entities/detail_generic.py @@ -126,14 +126,9 @@ def get(self, request, *args, **kwargs): ] entity_settings = get_entity_settings_by_modelname(self.entity) exclude_fields.extend(entity_settings.get("detail_view_exclude", [])) - for field in model_to_dict(self.instance).keys(): + for field, value in model_to_dict(self.instance).items(): if field not in exclude_fields: - relevant_fields.append( - ( - self.instance._meta.get_field(field), - getattr(self.instance, field), - ) - ) + relevant_fields.append((self.instance._meta.get_field(field), value)) return HttpResponse( template.render(