diff --git a/codeforlife/tests/model_view_set.py b/codeforlife/tests/model_view_set.py index 4ce34499..855bbf02 100644 --- a/codeforlife/tests/model_view_set.py +++ b/codeforlife/tests/model_view_set.py @@ -729,7 +729,7 @@ def assert_serialized_model_equals_json_model( model_serializer = model_view_set.get_serializer(model) # Serialize the model. - serialized_model = model_serializer.data + serialized_model = dict(model_serializer.data) # Recursively convert all datetimes to strings. def datetime_values_to_representation(data: DataDict): diff --git a/codeforlife/views/model.py b/codeforlife/views/model.py index 14ed52fa..7a030507 100644 --- a/codeforlife/views/model.py +++ b/codeforlife/views/model.py @@ -183,9 +183,9 @@ def bulk_create(self, request: Request[RequestUser]): serializer.is_valid(raise_exception=True) self.perform_bulk_create(serializer) return Response( - serializer.data, + dict(serializer.data), status=status.HTTP_201_CREATED, - headers=self.get_success_headers(serializer.data), + headers=self.get_success_headers(dict(serializer.data)), ) def perform_bulk_create( @@ -224,7 +224,7 @@ def bulk_partial_update(self, request: Request[RequestUser]): ) serializer.is_valid(raise_exception=True) self.perform_bulk_update(serializer) - return Response(serializer.data) + return Response(dict(serializer.data)) def perform_bulk_update( self, serializer: "ModelListSerializer[RequestUser, AnyModel]" @@ -303,7 +303,9 @@ def update( ) serializer.is_valid(raise_exception=True) serializer.save() - return Response(**(response_kwargs or {}), data=serializer.data) + return Response( + **(response_kwargs or {}), data=dict(serializer.data) + ) update.__name__ = name