Inherit kwargs from source modelfield #9554
Unanswered
lukaszett
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
-
Hey everyone,
I'm using a custom ModelSerializer that aliases some attributes to different names (in my case I'm using it to provide custom endpoints for different customers).
Think of the following
this is my serializer:
My naive expectation would be that any validators for Foo.name (such as max length or any custom validators) and the
required
attribute would also be applied to the serializer's field. However this is currently not the case. I'm solving this issue by just defining my ownget_fields
method which updates any fields that have a source set, to use the model's fields setting regarding validators and requiredness.Is that a behaviour that would be desirable to have in DRF?
Beta Was this translation helpful? Give feedback.
All reactions