'Model serializer without any fields
I would like to have serializer which only validate instance field "default" and return nothing. I want do that without picking any fields but I'm receving an error that i need to pick some fields or use all_, can you please help me what i can do then ?
class PaymentMethodDefaultSerializer(serializers.ModelSerializer):
class Meta:
model = PaymentMethod
def save(self, **kwargs):
instance = PaymentMethod.set_as_default(self.instance)
return instance
@staticmethod
def validate_default(value):
if value:
raise serializers.ValidationError(
'There is an default payment'
)
return value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
