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

from django.db.models.query import QuerySet


def pagination(queryset, page, num=10, strict=False):
    """
    Simple Pagination Funciton
    :param queryset:
    :param page:
    :param num: number per page
    :param strict: strict left number or not
    :return: matched query, left number(default not strict)
    """
    start, end = num * (page - 1), num * page
    return queryset[start: end], max(queryset.count() if isinstance(queryset, QuerySet) else len(queryset) - end,
                                     0) if strict else len(queryset[end: end + 1])
