Opened 10 years ago

Closed 10 years ago

#23550 closed Cleanup/optimization (fixed)

Normalize implementation of SingleRelatedObjectDescriptor.get_queryset() and ReverseSingleRelatedObjectDescriptor.get_queryset().

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

Description (last modified by Loic Bistuer)

Both SingleRelatedObjectDescriptor and ReverseSingleRelatedObjectDescriptor can return Manager instances which is inconsistent with the name of the method get_queryset().

ReverseSingleRelatedObjectDescriptor.get_queryset() instantiates a QuerySet directly which is problematic because it doesn't account for custom QuerySet types.

SingleRelatedObjectDescriptor.get_queryset() doesn't honor use_for_related_fields which is inconsistent with ReverseSingleRelatedObjectDescriptor.

Change History (3)

comment:1 by Loic Bistuer, 10 years ago

Description: modified (diff)

comment:3 by Loic Bistuer <loic.bistuer@…>, 10 years ago

Resolution: fixed
Status: newclosed

In e043aae9bb2e3fa244f59b07fc16f57476cb80ff:

Fixed #23550 -- Normalized get_queryset() of RelatedObjectDescriptor
and ReverseSingleRelatedObjectDescriptor so they actually return QuerySet
instances.

Also ensured that SingleRelatedObjectDescriptor.get_queryset() accounts
for use_for_related_fields=True.

This cleanup lays the groundwork for #23533.

Thanks Anssi Kääriäinen for the review.

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