Re: Building correct queryset

2017-05-25 Thread Горобец Дмитрий
Score field is on Brand model. пятница, 26 мая 2017 г., 3:19:56 UTC+5 пользователь Melvyn Sopacua написал: > > On Monday 22 May 2017 15:26:59 Todor Velichkov wrote: > > > Hello, Дмитрий, > > > you can try this one, but w/o further optimizations it may be a very > > > slow query. > > > > >

Re: Building correct queryset

2017-05-25 Thread Melvyn Sopacua
On Monday 22 May 2017 15:26:59 Todor Velichkov wrote: > Hello, Дмитрий, > you can try this one, but w/o further optimizations it may be a very > slow query. > > qs = Product.objects.filter( > #Where score is greater or equal > #to the 4th max score from its group > score__gte=Su

Re: Building correct queryset

2017-05-24 Thread Горобец Дмитрий
Thank you, Todor. I'll try. вторник, 23 мая 2017 г., 3:27:00 UTC+5 пользователь Todor Velichkov написал: > > Hello, Дмитрий, > you can try this one, but w/o further optimizations it may be a very slow > query. > > qs = Product.objects.filter( > #Where score is greater or equal > #to the 4

Re: Building correct queryset

2017-05-22 Thread Todor Velichkov
Hello, Дмитрий, you can try this one, but w/o further optimizations it may be a very slow query. qs = Product.objects.filter( #Where score is greater or equal #to the 4th max score from its group score__gte=Subquery( (Product.objects .filter(brand=OuterRef('brand')

Re: Building correct queryset

2017-05-21 Thread Горобец Дмитрий
Andrew, your solution works great for one brand. But I have more than one. суббота, 20 мая 2017 г., 0:20:18 UTC+5 пользователь Andrew Beales написал: > > brand = Brand.objects.get(title='mybrand') > products = Product.objects.filter(brand=brand).order_by('-score')[:4] > > ...gets you the top 4 pro

Re: Building correct queryset

2017-05-19 Thread Andrew Beales
brand = Brand.objects.get(title='mybrand') products = Product.objects.filter(brand=brand).order_by('-score')[:4] ...gets you the top 4 products in order for the brand On Friday, May 19, 2017 at 10:32:49 AM UTC+1, Горобец Дмитрий wrote: > > Hello. I have these two models. I have to show 4 or less