summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/models/query.py6
-rw-r--r--tests/or_lookups/models.py3
2 files changed, 4 insertions, 5 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 36ebec1905..1b3c2629d6 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -796,13 +796,13 @@ class QuerySet:
"""
Return a new QuerySet instance with filter_obj added to the filters.
- filter_obj can be a Q object (or anything with an add_to_query()
- method) or a dictionary of keyword lookup arguments.
+ filter_obj can be a Q object or a dictionary of keyword lookup
+ arguments.
This exists to support framework features such as 'limit_choices_to',
and usually it will be more natural to use other methods.
"""
- if isinstance(filter_obj, Q) or hasattr(filter_obj, 'add_to_query'):
+ if isinstance(filter_obj, Q):
clone = self._clone()
clone.query.add_q(filter_obj)
return clone
diff --git a/tests/or_lookups/models.py b/tests/or_lookups/models.py
index efe70ab8dd..bd1840338f 100644
--- a/tests/or_lookups/models.py
+++ b/tests/or_lookups/models.py
@@ -5,8 +5,7 @@ To perform an OR lookup, or a lookup that combines ANDs and ORs, combine
``QuerySet`` objects using ``&`` and ``|`` operators.
Alternatively, use positional arguments, and pass one or more expressions of
-clauses using the variable ``django.db.models.Q`` (or any object with an
-``add_to_query`` method).
+clauses using the variable ``django.db.models.Q``.
"""
from django.db import models