From 3b11969e80dd60b5d62497419d039c5ef06fbad5 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste <bleme@pm.me>
Date: Fri, 16 Aug 2019 12:39:53 +0200
Subject: [PATCH] update: use read depth on POST/PUT response object
 construction

---
 djangoldp/serializers.py  | 4 ----
 djangoldp/tests/models.py | 4 +++-
 djangoldp/views.py        | 6 ++++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/djangoldp/serializers.py b/djangoldp/serializers.py
index 54bc1b48..15a4c897 100644
--- a/djangoldp/serializers.py
+++ b/djangoldp/serializers.py
@@ -207,10 +207,6 @@ class LDPSerializer(HyperlinkedModelSerializer):
     serializer_url_field = JsonLdIdentityField
     ModelSerializer.serializer_field_mapping[LDPUrlField] = IdURLField
 
-    @property
-    def data(self):
-        return super().data
-
     def get_default_field_names(self, declared_fields, model_info):
         try:
             fields = list(self.Meta.model._meta.serializer_fields)
diff --git a/djangoldp/tests/models.py b/djangoldp/tests/models.py
index 823f2d18..31f0d497 100644
--- a/djangoldp/tests/models.py
+++ b/djangoldp/tests/models.py
@@ -116,6 +116,7 @@ class Batch(Model):
         authenticated_perms = ['inherit', 'add']
         owner_perms = ['inherit', 'change', 'delete', 'control']
         nested_fields = ["tasks", 'invoice']
+        depth = 1
 
 
 class Task(models.Model):
@@ -141,4 +142,5 @@ class Post(Model):
         owner_perms = ['inherit']
 
 
-get_user_model()._meta.serializer_fields = ['@id', 'username', 'first_name', 'last_name', 'email', 'userprofile', 'conversation_set',]
+get_user_model()._meta.serializer_fields = ['@id', 'username', 'first_name', 'last_name', 'email', 'userprofile',
+                                            'conversation_set', ]
diff --git a/djangoldp/views.py b/djangoldp/views.py
index 3879cd1f..39f0eb28 100644
--- a/djangoldp/views.py
+++ b/djangoldp/views.py
@@ -144,8 +144,10 @@ class LDPViewSet(LDPViewSetGenerator):
         serializer = self.get_write_serializer(data=request.data)
         serializer.is_valid(raise_exception=True)
         self.perform_create(serializer)
-        headers = self.get_success_headers(serializer.data)
-        return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
+        response_serializer = self.get_serializer()
+        data = response_serializer.to_representation(serializer.instance)
+        headers = self.get_success_headers(data)
+        return Response(data, status=status.HTTP_201_CREATED, headers=headers)
 
     def update(self, request, *args, **kwargs):
         partial = kwargs.pop('partial', False)
-- 
GitLab