def serialize_field(self, instance, field_name):
        method_name = 'serialize_{0}'.format(field_name)
        if hasattr(self, method_name):
            return getattr(self, method_name)(instance, field_name)

        try:
            field = self.model._meta.get_field(field_name)
        except FieldDoesNotExist:
            # Abstract field
            pass
        else:
            field_type_method_name = 'serialize_type_{0}'.format(
                field.__class__.__name__.lower())
            if hasattr(self, field_type_method_name):
                return getattr(self, field_type_method_name)(instance, field_name)

            if field.rel:
                # M2M
                if isinstance(field, ManyToManyField):
                    return [self.nested_serialize(r)
                            for r in getattr(instance, field.name).all()]

                rel = getattr(instance, field.name)
                # FK, OtO
                if rel:  # should be a model instance
                    if self.cur_depth >= self.max_depth:
                        return

                    return self.nested_serialize(rel)

        try:
            return getattr(instance, field_name)
        except __HOLE__:
            raise AttributeError("The serializer doesn't know how to serialize {0}, "
                                 "please provide it a {1} method."
                                 "".format(field_name, method_name))
dataset/ETHPy150Open liberation/django-elasticsearch/django_elasticsearch/serializers.py/EsModelToJsonMixin.serialize_field