2017-02-23 8 views
1

を設定し、オフセットを取得しますがありshops = shops.all()[of:per_page]of = 5per_page = 5は、クエリにLIMITクエリを実行し

があるが、問合せの戻り

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 

はなぜdosen't作業offestを理解することはできません

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) 

を設定しましたLIMIT(5,5)はどこですか?あなたはおそらくあなたのケースでは

shops = shops.all()[5:10] 

に従っている欲しいもの

答えて

関連する問題