Opened 3 months ago

Closed 3 months ago

#35419 closed New feature (wontfix)

Add support for creating records from a queryset

Reported by: Clemens Wolff Owned by: nobody
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 StackOverflow and the 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.

Change History (1)

comment:1 by David Sanders, 3 months ago

Resolution: wontfix
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top