Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested saving not working for deep relations #129

Open
sandeepbalagopal09 opened this issue Nov 12, 2020 · 0 comments
Open

Nested saving not working for deep relations #129

sandeepbalagopal09 opened this issue Nov 12, 2020 · 0 comments

Comments

@sandeepbalagopal09
Copy link

class UserSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ("username", "email", "first_name", "last_name")


class OrganizationSerializer(WritableNestedModelSerializer):

    user = UserSerializer(source="owner.organization_user.user")

    class Meta:
        model = Organization
        fields = ("name", "user")

I have serializer like this. The user in Organization is a very deep relation. Getting error

Cannot assign "{'organization_user': {'user': OrderedDict([('username', 'username'), ('email', '[email protected]'), ('first_name', 'Test'), ('last_name', 'Test')])}}": "Organization.owner" must be a "OrganizationOwner" instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant