That's a good point, but then the ird_number field (on UserProfile) is
inaccessible. I'd need to do something like

    User.objects.values('first_name', 'last_name', 'pk',
'userprofile__ird_number').annotate(
       Max('application__creation_date'),
    ).order_by('-application__creation_date__max').select_related()

but that raises

    FieldError: Invalid field name: 'userprofile__ird_number'

Greg




On 16 February 2010 10:13, Dj Gilcrease <digitalx...@gmail.com> wrote:
> On Mon, Feb 15, 2010 at 1:43 PM, Greg Brown <gregplaysgui...@gmail.com> wrote:
>> The queryset giving the problem is
>>
>> UserProfile.objects.values(
>>        'ird_number', 'user__first_name', 'user__last_name', 'user__pk',
>>    ).annotate(
>>        Max('user__application__creation_date'),
>>    ).order_by('-user__application__creation_date__max')
>
>
> It looks to me like you are trying to get more info from the User
> model then then UserProfile model, so maybe change your query to be
> based on the User not the UserProfile
>
>
> User.objects.values('first_name', 'last_name', 'pk').annotate(
>    Max('application__creation_date'),
> ).order_by('-application__creation_date__max').select_related()
>
> --
> 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.
>
>



-- 
http://gregbrown.co.nz/

-- 
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