[Django] #28830: List to Queryset

59 views
Skip to first unread message

Django

unread,
Nov 22, 2017, 7:28:36 AM11/22/17
to django-...@googlegroups.com
#28830: List to Queryset
-----------------------------------------+--------------------------------
Reporter: 0r1gamic | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Keywords: queryset, list
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------------
Querysets can be converted to list. But list cannot be converted to query
set. I wrote a new function in django.db.models.utils package.


{{{
from django.db.models.utils import list_to_queryset
queryset = list_to_queryset(object_list)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28830>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 22, 2017, 8:53:17 AM11/22/17
to django-...@googlegroups.com
#28830: Add a function to convert a list to a Queryset
-------------------------------------+-------------------------------------
Reporter: 0r1gamic | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: queryset, list | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* type: Uncategorized => New feature
* component: Core (Other) => Database layer (models, ORM)
* resolution: => wontfix


Comment:

I don't think this merits inclusion in Django. The code is simple enough
that it doesn't add much boilerplate for projects that want the behavior.

There are also several problems with the implementation that might be
footguns:
1) Ordering isn't preserved.
2) For large lists, the performance of
`model.objects.filter(pk__in=pk_list)` is usually poor.

--
Ticket URL: <https://code.djangoproject.com/ticket/28830#comment:1>

Reply all
Reply to author
Forward
0 new messages