Deprecated depth kwarg on select_related.

This is the start of a deprecation path for the depth kwarg on
select_related. Removing this will allow us to update select_related so
it chains properly and have an API similar to prefetch_related.

Thanks to Marc Tamlyn for spearheading and initial patch.

refs #16855
This commit is contained in:
Preston Holmes 2012-11-02 15:49:29 +00:00
parent 7b57a72d6d
commit 965cc0b1ff
4 changed files with 30 additions and 14 deletions

View file

@ -5,6 +5,7 @@ The main QuerySet implementation. This provides the public API for the ORM.
import copy
import itertools
import sys
import warnings
from django.core import exceptions
from django.db import connections, router, transaction, IntegrityError
@ -698,6 +699,9 @@ class QuerySet(object):
If fields are specified, they must be ForeignKey fields and only those
related objects are included in the selection.
"""
if 'depth' in kwargs:
warnings.warn('The "depth" keyword argument has been deprecated.\n'
'Use related field names instead.', PendingDeprecationWarning)
depth = kwargs.pop('depth', 0)
if kwargs:
raise TypeError('Unexpected keyword arguments to select_related: %s'