#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.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018f332c3b7d-c01f4597-7b4f-49e6-9b2f-71d60cb98379-000000%40eu-central-1.amazonses.com.