I have following model :
class Role(models.Model) :
class RoleTypes(models.TextChoices) :
PAID = 'P', 'Paid'
UNPAID = 'U', 'Unpaid'
COLLABORATION = 'C', 'Collaboration'
role_type = models.CharField(max_length=5, choices=RoleTypes.choices, default=RoleTypes.PAID)
role_count = models.IntegerField(default = 1, validators=[MinValueValidator(1), MaxValueValidator(10)])
And following serializer :
class RoleSerializer(serializers.ModelSerializer):
class Meta :
model = Role
fields = '__all__'
Now Role resource is created by passing following data in post request :
{'role_type':'P', 'role_count':2}
Is it possible that data sent in post request sets role_type = ‘Paid’ instead of ‘P’
2