Пример #1
0
 def filter_queryset(self, request, queryset, view):
     r = request.GET or request.POST
     if r.get('query'):
         query = QueryParser(queryset.model, r.get('query'))
         return query.extend_query(queryset)
     else:
         return queryset
Пример #2
0
 def filter_queryset(self, request, queryset, view):
     r = request.GET or request.POST
     if r.get('query'):
         query = QueryParser(queryset.model, r.get('query'))
         return query.extend_query(queryset)
     else:
         return queryset
Пример #3
0
    def _apply_sql_filter(self, queryset, request, context):
        if context.get('has_filters') is not None:
            return queryset
        if request is None or request.GET.get('query') is None:
            return queryset

        from localground.apps.lib.helpers import QueryParser
        query = QueryParser(self.model, request.GET.get('query'))
        if query.error:
            context.update({'error_message': query.error_message})
            return queryset

        # Add some information to the request context
        context.update({
            'filter_fields': query.populate_filter_fields(),
            'sql': query.query_text,
            'has_filters': True
        })
        return query.extend_query(queryset)