Haystack / Whoosh Index Generation Error

I am trying to configure haystack using whoosh. When I try to create an index [or any index command, for that matter], I get:

TypeError: Item in ``from list'' not a string

If I completely delete my search_indexes.py, I get the same error [so I assume that he cannot find this file at all]

what can cause this error? it is set to auto-detect, and I'm sure my application is installed, because I'm using it now.

Full trace:

    Traceback (most recent call last):
  File "./manage.py", line 17, in <module>
    execute_manager(settings)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 257, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 124, in <module>
    handle_registrations()
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 121, in handle_registrations
    search_sites_conf = __import__(settings.HAYSTACK_SITECONF)
  File "/Users/ghostrocket/Development/Redux/website/../website/search_sites.py", line 2, in <module>
    haystack.autodiscover()
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 83, in autodiscover
    app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__
TypeError: Item in ``from list'' not a string

and here is my search_indexes.py

from haystack import indexes
from haystack import site
from myproject.models import *

site.register(myobject)
+3
source share
4 answers

There seem to be two problems you are facing.

- , TypeError. , Haystack , INSTALLED_APPS search_indexes.py( ). , , from list . , , ,

, , search_indexes.py , , .

, ( ). ( haystack.indexes.SearchIndex) . . .

django-haystack Google Group, , , .

+1

TypeError .

: Python import.c. , , , __import__ builtin , .

- . a str. (. unicode) .

, : , / -, , , a str, unicode.

:

__import__('mylib.foo', globals(), locals(), [u'bar'])

:

__import__('mylib.foo', globals(), locals(), ['bar'])
__import__(u'mylib.foo', globals(), locals(), ['bar'])

, , , Python 2.x, , 3.x /unicode -.

+8

, django-tastypie v0.10. Py3 ​​ from __future__ import unicode_literals.

tastypie .

, , - , tastypie tastypie ( , virtualenv). .

+2

, , 5 - . , git, , , . unicode , .

, , :

  • python import
  • python,

. .pyc .pyo . .

.py :

find . -name "*.pyc" -exec rm -f {} \;
find . -name "*.pyo" -exec rm -f {} \;
+1

Source: https://habr.com/ru/post/1726731/


All Articles