Example #1
0
 def search(self, queries, fields=None, page=1, per_page=10):
     fill_ingredients()
     # 食材に一致すれば関連から取得
     if len(queries) == 1 and queries[0] in ingredients:
         contests = ingredients.get(queries[0]).contest_set.all()
         return {'hits': contests.count(), 'object_list': contests}
     else:
         if searcher is None:
             contests = self.filter(published_at__lte=datetime.now()) \
                 .filter(description__icontains=queries[0])
             return {'hits': contests.count(), 'object_list': contests}
         else:
             return searcher.search(self, queries, fields, page, per_page)
Example #2
0
 def search(self, queries, fields=None, page=1, per_page=10):
     if searcher is None:
         return {'hits': 0, 'object_list': []}
     else:
         return searcher.search(self, queries, fields, page, per_page)