Easier access to query_params, data and POST in Field class and subclasses #8386
Unanswered
LLyaudet
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
-
Hello,
I have a very simple feature request:
create the following 3 helper methods in class Field:
and maybe also these 3 methods :
(These last 3 methods are not necessary, but it exemplifies some use cases.)
Adding these methods in Field class where context property is defined would make it easy to have shorter and simpler code in some use cases.
Mainly in Serializers where we use data from query_params, mainly in SerializerMethodField get_...() method ;
for example when the SerializerMethodField makes an expensive calculus that must be explicitely required by the client of the API with a query_param or something else.
I would be happy to have your opinions about this feature request and to make a pull request if you accept it :)
Best regards,
Laurent Lyaudet
PS : Since the request is not available, I have not proposed the default value used in class Request :
QueryDict('', encoding=self._request._encoding)
for data/POSTMoreover, in some cases data may return simply {}.
For query_params/GET it defaults to QueryDict(mutable=True) in Django.
I have no problem with more clever default value if you have any suggestion.
Beta Was this translation helpful? Give feedback.
All reactions