Opened 13 years ago

Closed 11 years ago

#16856 closed New feature (fixed)

Add a way to clear select_related

Reported by: Carl Meyer Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: jdunck@…, seldon, botondus@…, timograham@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If you've got a queryset that has had select_related called on it (maybe passed to you from some other code you don't control) there's currently no documented way to clear out select_related.

One possible API is .select_related(None), which mirrors how .defer() works.

The combination of this and #16855 would make .select_related() and .defer() more consistent with each other, which would be nice.

Change History (8)

comment:1 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

There was a clear consensus on this API in #django-dev.

comment:2 by Jeremy Dunck, 13 years ago

Cc: jdunck@… added

comment:3 by seldon, 12 years ago

Cc: seldon added

comment:4 by Béres Botond, 11 years ago

Cc: botondus@… added

comment:5 by Béres Botond, 11 years ago

For anyone reading this, the undocumented hacky way to do this is:

qs.query.select_related = False

comment:7 by Tim Graham, 11 years ago

Cc: timograham@… added
Has patch: set

Added a release note & brought patch up to date.

https://github.com/django/django/pull/1234

comment:8 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 5074c75a37f88726f3ae057999144545881d3cfc:

Fixed #16856 - Added a way to clear select_related.

Thanks Carl for the suggestion and David Cramer for the patch.

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