You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if suppressing the autogeneration of a field if another field uses it as source would be a sensible default. I can imagine usecases where source is used to add another representation, instead of replacing the default one all together, and it's also a breaking change. I'll have to check, but I also think that it'd be different behaviour from what DRF's built-in ModelSerializer does.
DRF built-in serializers are a bit different since they allow partial models by default. But when I set __all__ as fields I indeed get the same behaviour.
I think probably it is more common that you have one representation of a field by 'source' and don't want to autogenerate another one, but seems hard to change now.
It would be nice if one could use 'source' to change the name of a field in serialized data:
Right now this autogenerates another related field with the name 'model' and expects both to be in the serializer input data.
As a workaround I have to exclude the original like this:
Our use case is that we have both references and subserialized objects in our API, and we use '_id' as a postfix to identify references.
The text was updated successfully, but these errors were encountered: