MCPcopy Index your code
hub / github.com/django-haystack/django-haystack / prepare

Method prepare

haystack/fields.py:93–115  ·  view source on GitHub ↗

Takes data from the provided object and prepares it for storage in the index.

(self, obj)

Source from the content-addressed store, hash-verified

91 return self._default
92
93 def prepare(self, obj):
94 """
95 Takes data from the provided object and prepares it for storage in the
96 index.
97 """
98 # Give priority to a template.
99 if self.use_template:
100 return self.prepare_template(obj)
101 elif self.model_attr is not None:
102 attrs = self.split_model_attr_lookups()
103 current_objects = [obj]
104
105 values = self.resolve_attributes_lookup(current_objects, attrs)
106
107 if len(values) == 1:
108 return values[0]
109 elif len(values) > 1:
110 return values
111
112 if self.has_default():
113 return self.default
114 else:
115 return None
116
117 def resolve_attributes_lookup(self, current_objects, attributes):
118 """

Calls 4

prepare_templateMethod · 0.95
has_defaultMethod · 0.95