Skip to content
Browse files

Minor cleanup of Lookup API

  • Loading branch information...
1 parent 2adf504 commit eac47766844b90e7d3269e7a8c012eee34ec0093 @akaariai akaariai committed
Showing with 5 additions and 21 deletions.
  1. +1 −10 django/db/models/
  2. +4 −11 docs/ref/models/lookups.txt
11 django/db/models/
@@ -1,6 +1,5 @@
from copy import copy
-from django.core.exceptions import FieldError
from django.conf import settings
from django.utils import timezone
from django.utils.functional import cached_property
@@ -29,18 +28,10 @@ def get_cols(self):
class Lookup(object):
lookup_name = None
- extract_class = None
def __init__(self, lhs, rhs):
self.lhs, self.rhs = lhs, rhs
- if rhs is None:
- if not self.extract_class:
- raise FieldError("Lookup '%s' doesn't support nesting." % self.lookup_name)
- else:
- self.rhs = self.get_prep_lookup()
- def get_extract(self):
- return self.extract_class(self.lhs)
+ self.rhs = self.get_prep_lookup()
def get_prep_lookup(self):
return self.lhs.output_type.get_prep_lookup(self.lookup_name, self.rhs)
15 docs/ref/models/lookups.txt
@@ -93,16 +93,9 @@ The process_rhs method is used to convert the right hand side into query string.
The rhs is the value given in the filter clause. It can be a raw value to
compare agains, a F() reference to another field or even a QuerySet.
-.. method:: get_extract()
-The get_extract method is used in nested lookups. It must return an Extract instance.
-.. classattribute:: Lookup.extract_class
-The default implementation of get_extract() will return an instance of extract_class.
-In addition there are some private methods - that is, implementing just the above
-mentioned attributes and methods is not enough, you must subclass Lookup instead.
+In addition the Lookup class has some private methods - that is, implementing
+just the above mentioned attributes and methods is not enough, instead you
+should subclass Lookup.
The Extract class
@@ -112,7 +105,7 @@ For example you could have an Extract that procudes modulo 3 of the given value.
In SQL this would be something like "author"."age" % 3.
Extracts are used in nested lookups. The Extract class must implement the query
-part interface.
+part interface. In addition the Extract should must lookup_name attribute.
A simple Lookup example

0 comments on commit eac4776

Please sign in to comment.
Something went wrong with that request. Please try again.