'Flattens an object for indexing.
This loads a template
(``search/indexes/{app_label}/{model_name}_{field_name}.txt``) and
returns the result of rendering that template. ``object`` will be in
its context.'

def prepare_template(self, obj):

    if ((self.instance_name is None) and (self.template_name is None)):
        raise SearchFieldError(u'This    field    requires    either    its    instance_name    variable    to    be    populated    or    an    explicit    template_name    in    order    to    load    the    correct    template.')
    if (self.template_name is not None):
        template_names = self.template_name
        if (not isinstance(template_names, (list, tuple))):
            template_names = [template_names]
    else:
        (app_label, model_name) = get_model_ct_tuple(obj)
        template_names = [(u'search/indexes/%s/%s_%s.txt' % (app_label, model_name, self.instance_name))]
    t = loader.select_template(template_names)
    return t.render({u'object': obj})
