예제 #1
0
 def get_queryset(self):
     options = {
         'active': True,
     }
     if settings.APPLICATION_CACHE:
         tag = Commercial.get_commercial_tag()
         if cache.hexists(tag, options):
             data = json.loads(cache.hget(tag, options))
         else:
             data = self.get_list()
             cache.hset(Commercial.get_commercial_tag(), options, json.dumps(data))
     else:
         data = self.get_list()
     return data
예제 #2
0
    def get_queryset(self):
        options = {
            'brand_id': self.request.GET.get('brand_id', ''),
            'brand__entry': self.request.GET.get('brand__entry', ''),
            'name': self.request.GET.get('name__icontains', ''),
            'page': self.request.GET.get('page', '')
        }
        if settings.APPLICATION_CACHE and self.cache_status:
            str(self.request.GET.get('brand__entry', ''))

            if cache.hexists(Commercial.get_commercial_tag(), options):
                data = json.loads(cache.hget('commercial_list', options))
            else:
                qs = super(CommercialListView, self).get_queryset()
                data = self.get_list(qs)
                cache.hset(Commercial.get_commercial_tag(), options, json.dumps(data))
        else:
            qs = super(CommercialListView, self).get_queryset()
            data = self.get_list(qs)
        return data