Why does Serializer get_fields require a deepcopy? #8976
Unanswered
mbitzos
asked this question in
Question & Answer
Replies: 1 comment
-
I would like to see example use cases |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team, can anyone explain to me if Serializer.get_fields is something that could potentially be overridden to skip over deepcopying?
See: https://github.com/encode/django-rest-framework/blob/master/rest_framework/serializers.py#L374
In my project I am using Django to serialize a lot of data, and for each data packet I am instantiating a serializer to validate the data. This works well except for the fact that this deepcopy takes up a ton of the processing time (95% of the time is spent deep copying the fields serializers).
I'm mainly wondering if this deepcopy could be skipped for myself (I can just override the method) by first trying to understand fully which circumstances this happens:
This allows users to dynamically modify the fields on a serializer instance without affecting every other serializer instance.
Im trying to wrap my head around when and if in my use-case other serializer instances are ever going to modify another serializer instance during validation but having trouble understand what that exactly means.
Beta Was this translation helpful? Give feedback.
All reactions