(self, instance, field_value_to_ignore=None)
return instance
Given an model instance to index with ES, return the value that
        should be put into ES for this field.
Given an model instance to index with ES, return the value that
        should be put into ES for this field.
Given an model instance to index with ES return the value that should be put into ES for this field .
def get_value_from_instance(self, instance, field_value_to_ignore=None):
        """
        Given an model instance to index with ES, return the value that
        should be put into ES for this field.
        """
        if not instance:
            return None

        for attr in self._path:
            try:
                instance = instance[attr]
            except (
                TypeError, AttributeError,
                KeyError, ValueError, IndexError
            ):
                try:
                    instance = getattr(instance, attr)
                except ObjectDoesNotExist:
                    return None
                except (TypeError, AttributeError):
                    try:
                        instance = instance[int(attr)]
                    except (
                        IndexError, ValueError,
                        KeyError, TypeError
                    ):
                        if self._required:
                            raise VariableLookupError(
                                "Failed lookup for key [{}] in "
                                "{!r}".format(attr, instance)
                            )
                        return None

            if isinstance(instance, models.manager.Manager):
                instance = instance.all()
            elif callable(instance):
                instance = instance()
            elif instance is None:
                return None

        if instance == field_value_to_ignore:
            return None

        # convert lazy object like lazy translations to string
        if isinstance(instance, Promise):
            return force_str(instance)

        return instance
def get_value_from_instance ( self , instance , field_value_to_ignore = None ) : if not instance : return None for attr in self . _path : try : instance = instance [ attr ] except ( TypeError , AttributeError , KeyError , ValueError , IndexError ) : try : instance = getattr ( instance , attr ) except ObjectDoesNotExist : return None except ( TypeError , AttributeError ) : try : instance = instance [ int ( attr ) ] except ( IndexError , ValueError , KeyError , TypeError ) : if self . _required : raise VariableLookupError ( "Failed lookup for key [{}] in " "{!r}" . format ( attr , instance ) ) return None if isinstance ( instance , models . manager . Manager ) : instance = instance . all ( ) elif callable ( instance ) : instance = instance ( ) elif instance is None : return None if instance == field_value_to_ignore : return None # convert lazy object like lazy translations to string if isinstance ( instance , Promise ) : return force_str ( instance ) return instance