Linked Questions

Popular Questions

I'm using SlugRelatedField in my serializer. I want to validate it on a case-insensitive basis, so I add postfix "__iexact" to the "slug_field" attr. And validation works as I need (case-insensitive).

class MySerializer(ModelSerializer):
    customer = serializers.SlugRelatedField(queryset=Customer.objects.all(),
                                            required=False,
                                            allow_null=True,
                                            slug_field='name__iexact')

But when I try to get serializer.data, the following error occurs:
* {AttributeError}'Customer' object has no attribute 'name__iexact'
How can it be solved?

Related Questions