I have a model Comment that when created may or may not create a new user. For this reason, my API requires a password field when creating a new comment. Here is my Comment
Thanks for your own answer, it helped me a lot :)
But I think this is a bit more generic, since I still want to call the method on the super serializer class
def restore_object(self, attrs, instance=None):
'''
we have to ensure that the temporary_password is attached to the model
even though it is no field
'''
commenter_pw = attrs.pop('comment_pw', None)
obj = super(
CommentCreateSerializer, self
).restore_object(attrs, instance=instance)
if commenter_pw:
obj.commenter_pw = commenter_pw
return obj