Custom fields to list-serializer init #8465
Unanswered
sevdog
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As of now it is possible to provide custom init arguments to a model serializer if the
__init__
method is overridden. However it is not possible to provide any custom init argument to a list serializer without overriding themany_init
method:django-rest-framework/rest_framework/serializers.py
Lines 150 to 165 in df92e57
In a case there should be some kind of custom validation logic which may depends from a custom param provided in init at the moment the only way to use this is to "proxy"
self.child
properties since no custom param will ever get passed to the list serializer.It could make sense to have an attribute in
ListSerializer
from which add kwargs to list serializer (or to control which kwargs will be received only by the list serializer).Beta Was this translation helpful? Give feedback.
All reactions