Mohideen bin Mohammed
Mohideen bin Mohammed

Reputation: 20147

How to import mixin into all serializer - Django Rest Framework

I am having n- number of serializers in my current app..

i want to add one more mixin in header like ModelSerializer into all serializer like,

class AdminSerializer(CustomMixin, serializers.ModelSerializer):

now i am applying manually.. is their a way to override to apply all together?

Upvotes: 0

Views: 607

Answers (1)

Gabriel Muj
Gabriel Muj

Reputation: 3805

You could create a class that is using the mixin (give a proper name):

class MyCustomSerializer(CustomMixin, serializers.ModelSerializer):
    pass

And then subclass each of the serializer from MyCustomSerializer.

Upvotes: 1

Related Questions