Skip to content
Advertisement

I want my django rest framework serializer to accept input but not add to model

I removed some fields from my model, but I want the serializer to still accept the fields as input. How do I have fields the serializer accepts but doesn’t use?

JavaScript

Advertisement

Answer

From http://www.django-rest-framework.org/api-guide/serializers/

You can add extra fields to a ModelSerializer or override the default fields by declaring fields on the class, just as you would for a Serializer class.

JavaScript
Advertisement