1
待辦事項查詢設置得到OFFSET,對查詢的限制設置
shops = Shop.objects.filter(
id__in=list(set(shop_ids)))
if kitchens:
shops = shops.filter(
cuisineshop__in=kitchens)
if min:
shops = shops.filter(
delivery_price__gte=min)
if max:
shops = shops.filter(
delivery_price__lte=max)
if sort_type == 1:
shops = shops.order_by('rate')
if sort_type == 3:
shops = shops.order_by('rate')
if sort_type == 4:
shops = shops.order_by('rate')
shops = shops.annotate(count=Count('name'))
shops = shops.all()[of:per_page]
print(shops.query)
有shops = shops.all()[of:per_page]
of = 5
,per_page = 5
但查詢返回
SELECT `catalog_shop`.`id`, `catalog_shop`.`name`, `catalog_shop`.`time_begin`, `catalog_shop`.`time_end`, `catalog_shop`.`phone`, `catalog_shop`.`preview`, `catalog_shop`.`delivery_price`, `catalog_shop`.`min_order`, `catalog_shop`.`del_wait_time`, `catalog_shop`.`is_always`, `catalog_shop`.`is_cash`, `catalog_shop`.`is_card`, `catalog_shop`.`is_online`, `catalog_shop`.`is_points`, `catalog_shop`.`notification`, `catalog_shop`.`email`, `catalog_shop`.`rate`, `catalog_shop`.`destination`, `catalog_shop`.`description`, `catalog_shop`.`cook`, `catalog_shop`.`image_cook`, `catalog_shop`.`desc_cook`, `catalog_shop`.`shoptype_id`, `catalog_shop`.`slider_id`, COUNT(`catalog_shop`.`name`) AS `count` FROM `catalog_shop` WHERE (`catalog_shop`.`id` IN (4, 5, 6, 7, 8, 9, 10) AND `catalog_shop`.`delivery_price` <= 10000) GROUP BY `catalog_shop`.`id` ORDER BY `catalog_shop`.`rate` ASC LIMIT 5
不明白爲什麼這麼想的工作offest wityh限制在哪裏LIMIT(5,5)?