I'm using django-haystack for searching on my site. I'm also using django multilingual model for I18n. I import MultilingualModel in search_indexes.py
I ca run all manangement commands as long as I don't have haystack in the INSTALLED_APPS.
When haystack is in the INSTALLED_APPS and try to run syncdb or migrate (and several other management commands) I'm always getting:
django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name MultilingualModel
search_indexes.py
doesn't get processed unless haystack is inINSTALLED_APPS
. The problem is with the import ofMultilingualModel
in general. Either it's not truly installed in your environment (attempt to import it from a vanilla python shell), or you have the import wrong (it's actually in another module, for example).Once you can successfully import
MultilingualModel
from a python shell, you won't have any problems.This is likely related to the hacks done in
haystack.autodiscover()
. This behavior is documented here: http://docs.haystacksearch.org/dev/debugging.html#import-errors-on-start-up-mentioning-handle-registrations There is a long discussion in this ticket: https://github.com/toastdriven/django-haystack/issues/84The long and short if it is that moving
haystack.autodiscover()
into yoururls.py
can sometimes resolve this issue. SettingHAYSTACK_ENABLE_REGISTRATIONS = False
when running syncdb or migrate has resolved this for me using this snippet in mysettings.py
: