class RegisterLookupMixin

from django.db.models.query_utils import RegisterLookupMixin


  

Ancestors (MRO)

  1. builtins.object
  2. django.db.models.query_utils.RegisterLookupMixin
AttributeValueDefined in
def get_class_lookups(self)
django.db.models.query_utils.RegisterLookupMixin
    @functools.cache
    def get_class_lookups(cls):
        class_lookups = [
            parent.__dict__.get("class_lookups", {}) for parent in inspect.getmro(cls)
        ]
        return cls.merge_dicts(class_lookups)
def get_instance_lookups(self)
django.db.models.query_utils.RegisterLookupMixin
    def get_instance_lookups(self):
        class_lookups = self.get_class_lookups()
        if instance_lookups := getattr(self, "instance_lookups", None):
            return {**class_lookups, **instance_lookups}
        return class_lookups
def get_lookup(self, lookup_name)
django.db.models.query_utils.RegisterLookupMixin
    def get_lookup(self, lookup_name):
        from django.db.models.lookups import Lookup

        found = self._get_lookup(lookup_name)
        if found is None and hasattr(self, "output_field"):
            return self.output_field.get_lookup(lookup_name)
        if found is not None and not issubclass(found, Lookup):
            return None
        return found
def get_transform(self, lookup_name)
django.db.models.query_utils.RegisterLookupMixin
    def get_transform(self, lookup_name):
        from django.db.models.lookups import Transform

        found = self._get_lookup(lookup_name)
        if found is None and hasattr(self, "output_field"):
            return self.output_field.get_transform(lookup_name)
        if found is not None and not issubclass(found, Transform):
            return None
        return found
def merge_dicts(dicts)
django.db.models.query_utils.RegisterLookupMixin
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
    @staticmethod
    def merge_dicts(dicts):
        """
        Merge dicts in reverse to preference the order of the original list. e.g.,
        merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
        """
        merged = {}
        for d in reversed(dicts):
            merged.update(d)
        return merged
def register_class_lookup(cls, lookup, lookup_name=None)
django.db.models.query_utils.RegisterLookupMixin
    def register_class_lookup(cls, lookup, lookup_name=None):
        if lookup_name is None:
            lookup_name = lookup.lookup_name
        if "class_lookups" not in cls.__dict__:
            cls.class_lookups = {}
        cls.class_lookups[lookup_name] = lookup
        cls._clear_cached_class_lookups()
        return lookup
def register_instance_lookup(self, lookup, lookup_name=None)
django.db.models.query_utils.RegisterLookupMixin
    def register_instance_lookup(self, lookup, lookup_name=None):
        if lookup_name is None:
            lookup_name = lookup.lookup_name
        if "instance_lookups" not in self.__dict__:
            self.instance_lookups = {}
        self.instance_lookups[lookup_name] = lookup
        return lookup