﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12549	Native list method sort() does not work on ValuesListQuerySet instance returned from value_list()  QuerySet	jonathan_livni	nobody	"'''The following code causes an exception:'''


{{{
    members = Member.objects.all().values_list('name',flat=True)
    members.sort(key=len,reverse=True)  # Sorts members so that longer strings are first
}}}

'''The exception is:'''


{{{
   Traceback (most recent call last):
     File ""members_update.py"", line 1179, in <module>
    uploadMembers(trace,mems.members,configuration=conf)
     File ""/usr/lib/python2.5/site-packages/django/db/transaction.py"", line 265, in _commit_manually
    return func(*args, **kw)
     File ""members_update.py"", line 186, in uploadProducts
    members.sort(key=len,reverse=True)  # Sorts members so that longer strings are first
   AttributeError: 'ValuesListQuerySet' object has no attribute 'sort'
}}}


As far as the documentation goes, value_list() QuerySet was supposed to return a List object, not a ValuesListQuerySet. The documentation specifically states that value_list does is one of the functions not returning a QuerySet. Even if there's some kind of need to to return a List object, at least you would expect it to behave like a List object and support its methods - such as sort()"		closed	Core (Other)	1.1-beta		invalid			Unreviewed	0	0	0	0	0	0
