mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
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:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user