my model has a field:
name = models.CharField(max_length=255, blank=True, null=True)
in serializer, I am trying to raise a unique validation error
name = serializers.CharField(validators=[UniqueValidator(queryset=Department.objects.all(),
message=("Name already exists"))])
but it does not work, because the data comes to the serializer in this format name: {en: "drink"}, in db fields are populated with drink only.
I can raise an error in the create method, but I want to raise the error on the serializer. appreciate any advice. I'm in a hurry. sorry for any inconvenience.
Thanks in advance