code: def query_model(self, model, condition=None, offset=None, limit=None,
                      order_by=None, group_by=None, having=None, fields=None):
          
          from uliweb import settings, request
          from uliweb.utils.common import log
          from uliweb.orm import rawsql
          
          if self._query is not None:
              query = self._query
              if condition is not None and isinstance(query, Result):
                  query = query.filter(condition)
          else:
              query = self.model.filter(condition)
  
          if request.GET.get('_debug_'):
              log.info(rawsql(query.get_query()))
          
          if self.pagination:
              if offset is not None:
                  query = query.offset(int(offset))
              if limit is not None:
                  query = query.limit(int(limit))
          if order_by is not None:
              if isinstance(order_by, (tuple, list)):
                  query = query.order_by(*order_by)
              else:
                  query = query.order_by(order_by)
          if group_by is not None:
              if isinstance(group_by, (tuple, list)):
                  query = query.group_by(*group_by)
              else:
                  query = query.group_by(group_by)
              if having is not None:
                  query = query.having(having)
          return query
docs: Query all records with limit and offset, it's used for pagination query.