class lookups.RegisterLookupMixin
A mixin that implements the lookup API on a class.
-
classmethod register_lookup(lookup, lookup_name=None) -
Registers a new lookup in the class. For example
DateField.register_lookup(YearExact)will registerYearExactlookup onDateField. It overrides a lookup that already exists with the same name.lookup_namewill be used for this lookup if provided, otherwiselookup.lookup_namewill be used.Changed in Django 1.9:The
lookup_nameparameter was added.
-
get_lookup(lookup_name) -
Returns the
Lookupnamedlookup_nameregistered in the class. The default implementation looks recursively on all parent classes and checks if any has a registered lookup namedlookup_name, returning the first match.
-
get_transform(transform_name) -
Returns a
Transformnamedtransform_name. The default implementation looks recursively on all parent classes to check if any has the registered transform namedtransform_name, returning the first match.
For a class to be a lookup, it must follow the Query Expression API. Lookup and Transform naturally follow this API.
Please login to continue.