feature(Field Label): Optionally Allow Field Label to be used In Plac…#6649
feature(Field Label): Optionally Allow Field Label to be used In Plac…#6649omkar-dsd wants to merge 1 commit into
Conversation
By optionally specifying the use_label flag in extra_kwargs, user can set the return field key to be label, which as of now is not configurable and is set to use the field.field_name
|
Hi @omkar-dsd. I'm going to close this for a few of reasons:
|
I would further clarify that this would not be a desirable behavior for the framework. If this is useful to you, I would encourage you to create this as a 3rd-party extension. |
|
There are many requests for this feature. We should optionally allow changing the field name in the response, instead of just making it a hard rule. I agree that the definition of label might not fit in this case, so we can use some other terminology. But such feature is really needed. |
|
This functionality has been mentioned in #967, but the feature has been rejected in that PR's form (the introduction a |
…e of Field Name #6648
By optionally specifying the use_label flag in extra_kwargs, user can set the return field key to be label, which as of now is not configurable and is set to use the field.field_name
Description
Meta:extra_kwargsto use field label as the return key.use_labelflag needs to be set to True. If done so,field.labelwill be picked as the return field key.use_labelis set to True, andlabelis specified at the same level in theextra_kwargs, the explicitly defined label will be picked. For Example:get_extra_kwargs()from ModelSerializer to its parent Serializer. Also handled the optionalMetaclass. Makes more sense asextra_kwargscan also be present in Non Model Serializer.