From 4075f775e76acbaf047d131e15c6eefe35b315de Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 20 Feb 2020 12:30:20 +0200 Subject: [PATCH] Implement prefer-inline for fetching items. --- django_etesync/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django_etesync/views.py b/django_etesync/views.py index 8724ae2..0c28974 100644 --- a/django_etesync/views.py +++ b/django_etesync/views.py @@ -99,6 +99,12 @@ class CollectionItemViewSet(BaseViewSet): pagination_class = paginators.LinkHeaderPagination lookup_field = 'uid' + def get_serializer_class(self): + if self.request.method == 'GET' and self.request.query_params.get('prefer_inline'): + return CollectionItemInlineSerializer + + return super().get_serializer_class() + def get_queryset(self): collection_uid = self.kwargs['collection_uid'] try: