DRF: Is there any way to keep ModelSerializer's auto-generated validators while using dynamic fields?

Viewed 18

I'm trying to have Django Rest Framework serializers with dynamic fields that depend on the context passed (request method, CRUD action etc.).

So I set the fields in self.fields when the serializer is initialized.

It works fine at the moment, but the problem is that I don't get the automatically generated validators that ModelSerializer provides. Is there any way to get those validators or do I have to resort to copy pasting validators from my models?

0 Answers
Related