from urllib import request

from django.core.paginator import Paginator
from django.shortcuts import render

# Create your views here.
from movie2app.models import TMovie


def showMovie2(request):
    #1.获取当前页码数
    num = request.GET.get('num',1)
    num = int(num)
    print(num)
    #2.查询表中所有数据
    movieList = TMovie.objects.all().order_by('id')
    #3.创建Django分页对象
    page_obj = Paginator(movieList,12)
    #4.获取当前页信息
    per_page = page_obj.page(num)
    
    return render(request,'movie2.html',{'per_page':per_page})