Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haystack + Whoosh throwing root:Error updating <appname> using default #1248

Open
davegri opened this issue Sep 30, 2015 · 2 comments
Open

Comments

@davegri
Copy link

davegri commented Sep 30, 2015

Django 1.8.4

django-haystack 2.4.0

Whoosh 2.7.0

python manage.py rebuild_index                                                                                                                                     ⏎ master ✖ ✱ ◼

WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
Indexing 1934 images
ERROR:root:Error updating crawlers using default 
Traceback (most recent call last):
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 188, in handle_label
    self.update_backend(label, using)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 233, in update_backend
    do_update(backend, index, qs, start, end, total, verbosity=self.verbosity, commit=self.commit)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 96, in do_update
    backend.update(index, current_qs, commit=commit)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/backends/whoosh_backend.py", line 196, in update
    doc = index.full_prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/indexes.py", line 212, in full_prepare
    self.prepared_data = self.prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/indexes.py", line 203, in prepare
    self.prepared_data[field.index_fieldname] = field.prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/fields.py", line 159, in prepare
    return self.convert(super(CharField, self).prepare(obj))
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/fields.py", line 106, in prepare
    return current_object()
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/db/models/fields/related.py", line 888, in __call__
    manager = getattr(self.model, kwargs.pop('manager'))
KeyError: 'manager'
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/rebuild_index.py", line 26, in handle
    call_command('update_index', **options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 183, in handle
    return super(Command, self).handle(*items, **options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/core/management/base.py", line 622, in handle
    label_output = self.handle_label(label, **options)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 188, in handle_label
    self.update_backend(label, using)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 233, in update_backend
    do_update(backend, index, qs, start, end, total, verbosity=self.verbosity, commit=self.commit)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 96, in do_update
    backend.update(index, current_qs, commit=commit)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/backends/whoosh_backend.py", line 196, in update
    doc = index.full_prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/indexes.py", line 212, in full_prepare
    self.prepared_data = self.prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/indexes.py", line 203, in prepare
    self.prepared_data[field.index_fieldname] = field.prepare(obj)
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/fields.py", line 159, in prepare
    return self.convert(super(CharField, self).prepare(obj))
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/haystack/fields.py", line 106, in prepare
    return current_object()
  File "/home/david/.virtualenvs/stocksearch/lib/python3.4/site-packages/django/db/models/fields/related.py", line 888, in __call__
    manager = getattr(self.model, kwargs.pop('manager'))
KeyError: 'manager'
@acdha
Copy link
Contributor

acdha commented Oct 2, 2015

Do you have a reproducible testcase for this? Based on the code in

attrs = self.model_attr.split('__')
current_object = obj
for attr in attrs:
if not hasattr(current_object, attr):
raise SearchFieldError("The model '%s' does not have a model_attr '%s'." % (repr(current_object), attr))
current_object = getattr(current_object, attr, None)
if current_object is None:
if self.has_default():
current_object = self._default
# Fall out of the loop, given any further attempts at
# accesses will fail miserably.
break
elif self.null:
current_object = None
# Fall out of the loop, given any further attempts at
# accesses will fail miserably.
break
else:
raise SearchFieldError("The model '%s' combined with model_attr '%s' returned None, but doesn't allow a default or null value." % (repr(obj), self.model_attr))
if callable(current_object):
return current_object()
I'm assuming this has something to do with resolving __ references in your model_attr setting.

@20083017
Copy link

seems you have a foreignkey in search indexes, remove that is one of the solutions ! just happen to meet the same problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants