Q:

Django rest framework - how to make case insensitive viewset search

How to enable case insensitive search in rest framework's viewsets? 
For example, assuming Post model has a tag.  All links below should find the same tag content, right now they are case sensitive and try to search for different values:

/posts/tag=AbcDef
/posts/tag=abcdef
/posts/tag=AbcdeF

views.py
class PostViewSet(viewsets. ReadOnlyModelViewSet):
    queryset = Post.objects.all()
    serializer_class = PostSerializer

A:

Assuming that you have field called tag in Post model and your search url is of the form:
/posts/?tag=AbcDef

You can do case sensitive search like:
class PostViewSet(viewsets. ReadOnlyModelViewSet): 
    serializer_class = PostSerializer

    def get_queryset(self):
        keyword = self.request.query_params.get('tag', '')
        queryset = Post.objects.filter(tag__iexact=keyword)
        return queryset

A:

Did you look into using http://www.django-rest-framework.org/api-guide/filtering/#searchfilter ?  That does case-insensitive searching by default.