#20408: values_list(flat=True) returns ValuesListQuerySet, not list
-------------------------------------+-------------------------------------
Reporter: marktranchant | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Documentation | Keywords: values_list queryset
Severity: Normal | list
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
The documentation should be updated to clarify that the structure returned
by a values_list queryset with flat=True is not a plain list, but a
ValuesListQuerySet. Alternatively, the code should actually output a list.
I spent a while struggling to understand why I couldn't use the Python
x.count(y) function on the output of such a query before realizing that I
wasn't working with a Python list:
{{{
> rlist = Rpt.objects.values_list('status', flat=True)
> type(rlist)
django.db.models.query.ValuesListQuerySet
> rlist.count(1)
TypeError: count() takes exactly 1 argument (2 given)
> rlist2 = list(Rpt.objects.values_list('status', flat=True))
> rlist2.count(1)
6
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20408>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.