#NEWLINE# @ list_route ( methods = [ 'get' ] , url_path = 'facets' ) #NEWLINE# def facets( self , request ) : #NEWLINE# #INDENT# '\n        Sets up a list route for ``faceted`` results.\n\n        This will add ie ^search/facets/$ to your existing ^search pattern.\n        ' #NEWLINE# queryset = self . filter_facet_queryset ( self . get_queryset ( ) ) #NEWLINE# for facet in request . GET . getlist ( 'selected_facets' ) : #NEWLINE# #INDENT# if ( ':' not in facet ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( field , value ) = facet . split ( ':' , 1 ) #NEWLINE# if value : #NEWLINE# #INDENT# queryset = queryset . narrow ( ( '%s:"%s"' % ( request , queryset . query . clean ( value ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# page = self . paginate_queryset ( queryset ) #NEWLINE# if ( page is not None ) : #NEWLINE# #INDENT# serializer = self . get_facet_serializer ( queryset . facet_counts ( ) , objects = page , many = False ) #NEWLINE# return Response ( serializer . data ) #NEWLINE# #UNINDENT# serializer = self . get_facet_serializer ( queryset . facet_counts ( ) , objects = queryset , many = False ) #NEWLINE# return Response ( serializer . data )