Example #1
0
def Pagination(request, number):
    """
    This is for pagination page
    """
    Page = get_post_pagination(number)
    if (Page.number < number) or (Page.number == 1):
        return redirect('index')
    HasPrevious = Page.has_previous()
    if HasPrevious:
        PreviousNumber = Page.previous_page_number()
    else:
        PreviousNumber = None
    HasNext = Page.has_next()
    if HasNext:
        NextNumber = Page.next_page_number()
    else:
        NextNumber = None
    return render(
        request, 'index.html', {
            'page': Page,
            'has_previous': HasPrevious,
            'has_next': HasNext,
            'previous_number': PreviousNumber,
            'next_number': NextNumber
        })
Example #2
0
def index(request):
    """
    This view use for index page of the site
    """
    Page = get_post_pagination(1)
    HasNext = Page.has_next()
    if HasNext:
        NextNumber = Page.next_page_number()
    else:
        NextNumber = None
    return render(
        request, 'index.html', {
            'page': Page,
            'has_next': HasNext,
            'has_previous': False,
            'next_number': NextNumber
        })