def paginate(self, q):
        """
        Filters the query so that a given page is returned. The record count
        is computed automatically from query.
        :param q: Query to be paged.
        :return: Paged query.
        """
        self.record_count = q.count()
        return self.apply_pagination(q).all()