[Django] #35419: Add support for creating records from a queryset

7 views
Skip to first unread message

Django

unread,
May 1, 2024, 4:01:35 AMMay 1
to django-...@googlegroups.com
#35419: Add support for creating records from a queryset
-------------------------------------+-------------------------------------
Reporter: c-w | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version:
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
For performing efficient inserts based on existing data, it would be great
if Django could offer support for the ANSI SQL **INSERT INTO ... SELECT
FROM ...**, perhaps something along the lines of the following snippet:

{{{
queryset = MyTable.objects.filter(field=value)
MyTable.objects.create_from(queryset)
}}}

Currently this type of insertion is only possible by bypassing the ORM or
by evaluating the queryset and then doing a bulk_create. The former is
undesirable for maintainability and the latter is inefficient as it
executes 2 queries and potentially transfers a lot of data over the
network.

The feature has been requested in a few other places such as
[https://stackoverflow.com/questions/70888534/ StackOverflow] and the
[https://forum.djangoproject.com/t/14648/ Django Forum] so I figured that
it would be a good idea to open an actual ticket for it.

If the feature request were to be accepted, I can work on a patch for it
if provided with some high-level guidance.
--
Ticket URL: <https://code.djangoproject.com/ticket/35419>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 1, 2024, 6:01:55 AMMay 1
to django-...@googlegroups.com
#35419: Add support for creating records from a queryset
-------------------------------------+-------------------------------------
Reporter: Clemens Wolff | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* resolution: => wontfix
* status: new => closed

Comment:

Thanks for the ticket though all feature requests must be a result of a
forum thread showing consensus for support:
https://code.djangoproject.com/wiki/DevelopersMailingList#BeenWONTFIXed
--
Ticket URL: <https://code.djangoproject.com/ticket/35419#comment:1>
Reply all
Reply to author
Forward
0 new messages