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

How to override create method in DynamicModelSerializer so that an object of the nested serializer can be created #314

Open
xtrm-co-in opened this issue Dec 1, 2020 · 0 comments

Comments

@xtrm-co-in
Copy link

xtrm-co-in commented Dec 1, 2020

I have a Transaction model having OneToMany (Foreignkey) relation with Details model. i.e. One transaction can have multiple details. I have nested Details serializer within Transaction serializer which works fine for listing and retrieving. However, I want to override create method in Transaction serializer in such a way that I can create an instance of Details object from the list provided in the request body while simultaneously creating an instance of the Transaction Object. Create method that I have overridden in drf's ModelSerializer works just fine but same isn't working with DynamicModelSerializer. Can you please guide me on how to do it ?

@xtrm-co-in xtrm-co-in changed the title How to override create method so that an object of the nested serializer can be created How to override create method in DynamicModelSerializer so that an object of the nested serializer can be created Dec 1, 2020
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