daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jan 21st, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from haystack.query import SearchQuerySet
  2.  
  3. class MyResource(Resource):
  4.     def build_filters(self, filters=None):
  5.         if filters is None:
  6.             filters = {}
  7.  
  8.         orm_filters = super(MyResource, self).build_filters(filters)
  9.  
  10.         if "q" in filters:
  11.             sqs = SearchQuerySet().auto_query(filters['q'])
  12.  
  13.             orm_filters = {"pk__in": [ i.pk for i in sqs ]}
  14.  
  15.         return orm_filters
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top