On Tue, Jun 15, 2010 at 7:56 AM, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 14 juin, 22:17, Lee Hinde <leehi...@gmail.com> wrote:
>> This started off as a pagination question, but then I realized it was
>> a different issue:
>>
>> Given:http://dpaste.com/hold/207217/
>
>
>    u = notes.filter(Q(recipient__user = id) |
> Q(store_as_text="All")).distinct()
>    u = notes.filter(recipient__user = id)
>
> OT but - You're aware that the second statements discards all results
> from the first one ?

I added the 2nd filter to see if the distinct() made a difference in
the outcome. I should have commented the first one out.

>    n = u.select_related().order_by('-target_date','-id')
>    agg = _aggregation(n,request)
>
> What is '_aggregation' ?

_aggregation creates a 2nd queryset

def _aggregation(notes,request):
    if _is_manager_or_above(request):
        agg = notes.aggregate(Sum('lunch'),Sum('dinner'),Sum('catering'))
    else:
        agg = {}
        agg['lunch__sum'] = Decimal(0)
        agg['dinner__sum'] = Decimal(0)
        agg['catering__sum'] = Decimal(0)
    return agg



> #    print(len(n))
>    paginator = Paginator(n,10)
>
>    try:
>        page = int(request.GET.get('page', '1'))
>    except ValueError:
>        page = 1
>
>    try:
>        paged_notes = paginator.page(page)
>    except (EmptyPage, InvalidPage):
>        paged_notes = paginator.page(paginator.num_pages) #last page.
>
>    print paged_notes.paginator.count
>
>> why would  len(n)  be different  than n.count()
>
> cf my question above.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to