How to correctly inherit custom serializer to add new field

1,718 views
Skip to first unread message

Kaushil Kundalia

unread,
Apr 14, 2021, 2:04:26 PM4/14/21
to Django REST framework

Here is my parent serializer:
image_2021-04-14_232224.png

Now, I want to add a new field "field_child_1" on a serializer that inherits from the ParentSerializer. I have tried 2 approaches yet both of them are throwing the same error. Here is what I have done:

image_2021-04-14_232920.png

Below is the error that I am facing:
image_2021-04-14_233232.png

Now my question is, how can I add new fields in my child serializer after inheriting from ParentSerializer.

Any help is sincerely appreciated and hope you have a great day ^_^

Chetan Ganji

unread,
Apr 16, 2021, 5:18:46 PM4/16/21
to django-res...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/40a42227-ce4b-4a9d-9faf-4819c27b39f9n%40googlegroups.com.

Kaushil Kundalia

unread,
Apr 24, 2021, 9:38:50 AM4/24/21
to Django REST framework
Thanks for your help. With a little bit of modification, this approach worked. 
Reply all
Reply to author
Forward
0 new messages