Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Address #16855 - Deprecate depth kwarg on select_related. #488

Closed
wants to merge 1 commit into from

3 participants

@mjtamlyn
Collaborator

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 a more similar API to prefetch_related.

@mjtamlyn mjtamlyn Address #16855 - Deprecate 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 a more similar API to prefetch_related.
931c2f7
@aaugustin aaugustin commented on the diff
django/db/models/query.py
@@ -698,6 +699,8 @@ def select_related(self, *fields, **kwargs):
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 keyword argument "depth" has been deprecated. Use field names instead.', DeprecationWarning)
@aaugustin Owner

This should be a PendingDeprecationWarning at this time. (Also a \n would help readability.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ptone ptone commented on the diff
docs/ref/models/querysets.txt
@@ -622,6 +622,11 @@ select_related
.. method:: select_related()
+.. deprecated:: 1.5
+ The ``depth`` parameter to ``select_related()`` has been deprecated. You
+ should replace it with the use of the ``(*fields)`` format instead. See the
+ :doc:`Django 1.5 release notes</releases/1.5>` for more information.
@ptone Collaborator
ptone added a note

FYI - the deprecated sphinx directive automatically inserts a "see release notes" link

@ptone Collaborator
ptone added a note

I'm wrong that is only for version added - but in this case the release note doesn't add much, if anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ptone
Collaborator

merged with some extra docs modifications in 965cc0b

@ptone ptone closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 2, 2012
  1. @mjtamlyn

    Address #16855 - Deprecate depth kwarg on select_related.

    mjtamlyn authored
    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 a more similar API to prefetch_related.
This page is out of date. Refresh to see the latest.
View
3  django/db/models/query.py
@@ -5,6 +5,7 @@
import copy
import itertools
import sys
+import warnings
from django.core import exceptions
from django.db import connections, router, transaction, IntegrityError
@@ -698,6 +699,8 @@ def select_related(self, *fields, **kwargs):
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 keyword argument "depth" has been deprecated. Use field names instead.', DeprecationWarning)
@aaugustin Owner

This should be a PendingDeprecationWarning at this time. (Also a \n would help readability.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
depth = kwargs.pop('depth', 0)
if kwargs:
raise TypeError('Unexpected keyword arguments to select_related: %s'
View
3  docs/internals/deprecation.txt
@@ -298,6 +298,9 @@ these changes.
* The ``daily_cleanup.py`` script will be removed.
+* The ``depth`` keyword argument will be removed from
+ :meth:`~django.db.models.query.QuerySet.select_related`.
+
2.0
---
View
5 docs/ref/models/querysets.txt
@@ -622,6 +622,11 @@ select_related
.. method:: select_related()
+.. deprecated:: 1.5
+ The ``depth`` parameter to ``select_related()`` has been deprecated. You
+ should replace it with the use of the ``(*fields)`` format instead. See the
+ :doc:`Django 1.5 release notes</releases/1.5>` for more information.
@ptone Collaborator
ptone added a note

FYI - the deprecated sphinx directive automatically inserts a "see release notes" link

@ptone Collaborator
ptone added a note

I'm wrong that is only for version added - but in this case the release note doesn't add much, if anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
Returns a ``QuerySet`` that will automatically "follow" foreign-key
relationships, selecting that additional related-object data when it executes
its query. This is a performance booster which results in (sometimes much)
View
7 docs/releases/1.5.txt
@@ -638,3 +638,10 @@ The :djadmin:`cleanup` management command has been deprecated and replaced by
The undocumented ``daily_cleanup.py`` script has been deprecated. Use the
:djadmin:`clearsessions` management command instead.
+
+``depth`` keyword argument in ``select_related``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``depth`` keyword argument in
+:meth:`~django.db.models.query.QuerySet.select_related` has been deprecated.
+You should use field names instead.
Something went wrong with that request. Please try again.