def retrieve(self, request, *args, **kwargs): query = kwargs['query'] user_ids = [] query = query.replace("+", " ") query_error, results = get_search_results(query) for unserialized_user in results: user_ids.append(unserialized_user.id) queryset = User.objects.filter(pk__in=user_ids) users = self.paginate_queryset(queryset) response = [] for user in users: if user.is_student: response.append( StudentSerializer(user, context={ 'request': request }).data) else: response.append( CounselorTeacherSerializer(user, context={ 'request': request }).data) return self.get_paginated_response(response)
def retrieve(self, request, *args, **kwargs): query = kwargs['query'] user_ids = [] query = query.replace("+", " ") query_error, results = get_search_results(query) for unserialized_user in results: user_ids.append(unserialized_user.id) queryset = User.objects.filter(pk__in=user_ids) users = self.paginate_queryset(queryset) response = [] for user in users: if user.is_student: response.append(StudentSerializer(user, context={'request': request}).data) else: response.append(CounselorTeacherSerializer(user, context={'request': request}).data) return self.get_paginated_response(response)