2017-02-23 1 views
1

마 쿼리가 shops = shops.all()[of:per_page]of = 5, per_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 

왜 나던 작업 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) 

세트 wityh 한도 LIMIT (5,5)? 당신은 아마도 귀하의 경우에는

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

을 따르고 원하는

답변

관련 문제