divio / aldryn-search

Haystack 2.0 search index for django CMS
Other
48 stars 77 forks source link

TypeError: sequence item 1: expected string or Unicode, instancemethod found #22

Closed marcosguedes closed 9 years ago

marcosguedes commented 9 years ago

Hi there. After configuring the search, I've come across an error while doind a rebuild_index, as follows:

TypeError: sequence item 1: expected string or Unicode, instancemethod found

Traceback:

Traceback (most recent call last): File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 221, in handle_label self.update_backend(label, using) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 266, in update_backend do_update(backend, index, qs, start, end, total, self.verbosity) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 89, in do_update backend.update(index, current_qs) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/haystack/backends/whoosh_backend.py", line 189, in update doc = index.full_prepare(obj) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/haystack/indexes.py", line 204, in full_prepare self.prepared_data = self.prepare(obj) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/aldryn_search/base.py", line 42, in prepare self.prepared_data['text'] = self.get_search_data(obj, current_language, request) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/aldryn_search/search_indexes.py", line 65, in get_search_data return clean_join(' ', text_bits) File "/home/marcos/django/project.git/env/local/lib/python2.7/site-packages/aldryn_search/utils.py", line 32, in clean_join return separator.join(filter(None, iterable))

settings

HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(PROJECT_PATH, '../../whoosh_index'), }, }

HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ] ALDRYN_SEARCH_LANGUAGE_FROM_ALIAS = None ALDRYN_SEARCH_PAGINATION = 10

I'm using Django 1.5.8

czpython commented 9 years ago

Looks to me like this issue is related to your own indexes, which are linked to your models. Could you check the indexes you have registered ? all clean_join does is check for None values in your iterable, so I would to a try/except and see what is the value of iterable when it fails.

marcosguedes commented 9 years ago

I did what you suggested and printed the value of iterable.

At first it gave me the titles of every word on a slideshow plugin created for the homepage. I have an inline class with an attribute called ´title´. I guess that's why it also joined it?

Before slideshow removal:

[u'IWS', pocket', u'watch'] [u'IWS pocket watch', <bound method Page.get_meta_keywords of <cms.models.pagemodel.Page object at 0xa995e6c>>] TypeError: sequence item 1: expected string or Unicode, instancemethod found

After slideshow removal:

[<bound method Page.get_meta_keywords of <cms.models.pagemodel.Page object at 0xa53c32c>>] TypeError: sequence item 0: expected string, instancemethod found

Thanks

czpython commented 9 years ago

Got it. Thanks :+1: