def get(self, request, page_num):
    orders = OrderInfo.objects.filter(user=request.user).order_by('-create_time')
    for order in orders:
        order.status_name = OrderInfo.ORDER_STATUS_CHOICES[(order.status - 1)][1]
        order.pay_method_name = OrderInfo.PAY_METHOD_CHOICES[(order.pay_method - 1)][1]
        order.sku_list = []
        lines = order.skus.all()
        for line in lines:
            sku = line.sku
            sku.count = line.count
            sku.amount = (sku.price * sku.count)
            order.sku_list.append(sku)
    page_num = int(page_num)
    try:
        paginator = Paginator(orders, 2)
        page_orders = paginator.page(page_num)
        total_page = paginator.num_pages
    except Exception as e:
        return HttpResponseForbidden('分页失败')
    context = {'total_page': total_page, 'page_orders': page_orders, 'page_num': page_num}
    return render(request, 'user_center_order.html', context)
def get(self, request, page_num):
    orders = OrderInfo.objects.filter(user=request.user).order_by('-create_time')
    for order in orders:
        order.status_name = OrderInfo.ORDER_STATUS_CHOICES[(order.status - 1)][1]
        order.pay_method_name = OrderInfo.PAY_METHOD_CHOICES[(order.pay_method - 1)][1]
        order.sku_list = []
        lines = order.skus.all()
        for line in lines:
            sku = line.sku
            sku.count = line.count
            sku.amount = (sku.price * sku.count)
            order.sku_list.append(sku)
    page_num = int(page_num)
    try:
        paginator = Paginator(orders, 2)
        page_orders = paginator.page(page_num)
        total_page = paginator.num_pages
    except Exception as e:
        return HttpResponseForbidden('分页失败')
    context = {'total_page': total_page, 'page_orders': page_orders, 'page_num': page_num}
    return render(request, 'user_center_order.html', context)