From a4a8145ccd3d4c051597bd7a185a04541003f8eb Mon Sep 17 00:00:00 2001 From: Ryo Chijiiwa Date: Mon, 21 Sep 2015 16:46:27 -0700 Subject: [PATCH] metadata updates: add resource names, use plural name for related_to --- dynamic_rest/metadata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dynamic_rest/metadata.py b/dynamic_rest/metadata.py index d03a27a7..78e9286d 100644 --- a/dynamic_rest/metadata.py +++ b/dynamic_rest/metadata.py @@ -24,6 +24,10 @@ def determine_metadata(self, request, view): metadata['features'] = getattr(view, 'features', []) if hasattr(view, 'get_serializer'): serializer = view.get_serializer(dynamic=False) + if hasattr(serializer, 'get_name'): + metadata['resource_name'] = serializer.get_name() + if hasattr(serializer, 'get_plural_name'): + metadata['resource_name_plural'] = serializer.get_plural_name() metadata['properties'] = self.get_serializer_info(serializer) return metadata @@ -52,7 +56,7 @@ def get_field_info(self, field): many = True if isinstance(field, ModelSerializer): type = 'many' if many else 'one' - field_info['related_to'] = field.get_name() + field_info['related_to'] = field.get_plural_name() else: type = self.label_lookup[field]