SELECT DISTINCT products_product id products_product priority FROM pro

1
SELECT DISTINCT `products_product`.`id`, `products_product`.`priority` FROM `products_product` LEFT OUTER JOIN `products_game` ON (`products_product`.`game_id` = `products_game`.`id`) LEFT OUTER JOIN `products_vips` ON (`products_game`.`id` = `products_vips`.`game_id`) WHERE CASE WHEN (`products_product`.`visibility` = 'v') THEN NOT (`products_vips`.`user_id` IS NULL) WHEN (`products_product`.`visibility` = 'i') THEN (`products_vips`.`user_id` IS NULL) ELSE 1 END = 1 ORDER BY `products_product`.`priority` DESC LIMIT 21; args=('v', 'i', True, True)