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 registerYearExact
lookup onDateField
. It overrides a lookup that already exists with the same name.lookup_name
will be used for this lookup if provided, otherwiselookup.lookup_name
will be used.Changed in Django 1.9:The
lookup_name
parameter was added.
-
get_lookup(lookup_name)
-
Returns the
Lookup
namedlookup_name
registered 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
Transform
namedtransform_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.