Skip to content

Nested serializer does not receive view context #2555

Closed
@iorlas

Description

@iorlas

It isn't stackoverflow question IMO, so excuse me if it is

I'm trying to use nested serializers, I know it is tough to discuss since we had so many problems in v2-branch. I want nested serializer field to use default based on selected project.

Project ID provided in QUERY_PARAMS and applies in perform_create like it should now, in v3-branch. But I need project in some nested serializer field BEFORE save - I want to provide default values for object in serializer metadata, so user will be able to change some things, which optionally can be taken from project object.

So, I populate context in get_serializer_context with project object. And I should just rewrite __init__ in nested serializer to set defaults, ye?

The problem is, nested serializer does not recieve context nor parent in __init__. It seems, it does not recieve context at all! So, it should be a regression since pull-request 497.

I think, it isn't regression, more like design change, but I really need context to be able to change serizliser behavior!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions