# -*- coding: utf-8 -*-

from django.db.models.query import QuerySet


def pagination(queryset, page, num=10):
    """
    DIY Pagination Funciton
    :param queryset:
    :param page:
    :param num: the number of query for one page
    :return: the query of the page, the number of query left after the page
    """
    start, end, total = num * (page - 1), num * page, queryset.count() if isinstance(queryset, QuerySet) else len(queryset)
    return queryset[start: end], max(total - end, 0)
