Categories
Mastering Development

Search , Filter by SlugRelatedField in view

I have a problem with searching , filtering by SlugRelatedFiled which I get it in Serializers in Django Rest Framework .I just want to filter , search by category names of products. Here is my serializer. class CosmeticDetailSerializer(serializers.HyperlinkedModelSerializer): category = serializers.SlugRelatedField( queryset=CosmeticCategory.objects.filter(), slug_field=”name”, ) class Meta: model = Cosmetic #read_only_fields = [“date_added”, “date_updated”] fields = […]