xtlc
xtlc

Reputation: 1378

DRF: serializer validation without a model

Is the validate_fieldname method not called when not using a ModelSerializer? I am trying to validate my input:

class SomeSerializer(serializers.Serializer):
   serial = serializers.CharField()

    class Meta:
        fields = ["serial",]

    def validate_serial(self, value):
        if value ... 
        return value 

I want to use a validator method on the input of serial, but I do not have a related model I could use.

Upvotes: 0

Views: 1686

Answers (1)

Klim Bim
Klim Bim

Reputation: 646

Yes it does. The doc helps. It is not necessary to use a model.

Upvotes: 1

Related Questions