On Fri, Feb 11, 2011 at 3:59 PM, kyleduncan <kyledunca...@googlemail.com> wrote:
> Thank you! Not sure how to work it just yet though. do I replace x
> with user?  i tried this:
>
> results = results.sort(key=lambda x: x.last_login, reverse=True)
>
> and got an error  that the Profile object didn't have the attribute
> last_login


If some of the objects in your list have the attribute last_login and
others do not then you'll have to make a custom cmp function and pass
it to the sort call.

If not, and each object in your list has a user which has a
last_login, then replace x.last_login with x.user.last_login and it
should work.

The 'x' is insignificant. You can replace it in both cases with
'profile' if it makes your code more readable.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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