我查看了名为error_django.log
的Apache的错误日志,发现我的Haystack配置不正确。
我已浏览过文档但未找到任何错误配置的内容。
这是我的设置文件
ENABLE_SEARCH_STATISTICS = True
DJANGO_MEMCACHED_REQUIRE_STAFF = True
SERIALIZATION_MODULES = {
'json': 'wadofstuff.django.serializers.json'
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.xapian_backend.XapianEngine',
'PATH': '/home/kbuzz/xapian_index',
'BATCH_SIZE': 100,
},
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '/home/kbuzz/memcached.sock',
}
}
CACHE_MIDDLEWARE_ALIAS = "default"
CACHE_MIDDLEWARE_SECONDS = 360
CACHE_MIDDLEWARE_KEY_PREFIX = "kb"
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.messages',
'django.contrib.markup',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.redirects',
'django.contrib.humanize',
'autocomplete_light',
'memcache_status',
'djangorestframework',
'haystack',
'lamusoftware.generic',
'mptt',
'bootstrapform',
'sorl.thumbnail',
'south',
'oauth2client',
'articles',
'banners',
'common',
'directory',
'events',
'galleries',
'marketplace',
'movies',
'pages',
'profiles',
'search',
'stats',
'minidetector',
'mobile',
'reports',
'favorites',
'braces',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'widget_tweaks',
'wordofmouth',
'ckeditor',
'django_mobile',
'debug_toolbar',
)
#SOUTH_MIGRATION_MODULES = {
# 'auth': 'profiles.authmigrations',
#}
DEBUG_TOOLBAR_PATCH_SETTINGS = False
和错误日志
[Fri Oct 16 10:02:23 2015] [error] Internal Server Error: /biz-directory/category/directory/retail/shopping-malls
[Fri Oct 16 10:02:23 2015] [error] Traceback (most recent call last):
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/lib/python2.7/django/core/handlers/base.py", line 92, in get_response
[Fri Oct 16 10:02:23 2015] [error] response = middleware_method(request)
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/lib/python2.7/newrelic-2.44.0.36/newrelic/hooks/framework_django.py", line 220, in wrapper
[Fri Oct 16 10:02:23 2015] [error] return wrapped(*args, **kwargs)
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/webapps/django/kb/kb/middleware/log_ip_middleware.py", line 29, in process_request
[Fri Oct 16 10:02:23 2015] [error] user.save()
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/lib/python2.7/django/db/models/base.py", line 546, in save
[Fri Oct 16 10:02:23 2015] [error] force_update=force_update, update_fields=update_fields)
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/lib/python2.7/django/db/models/base.py", line 570, in save_base
[Fri Oct 16 10:02:23 2015] [error] update_fields=update_fields)
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/lib/python2.7/django/dispatch/dispatcher.py", line 170, in send
[Fri Oct 16 10:02:23 2015] [error] response = receiver(signal=self, sender=sender, **named)
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/webapps/django/kb/src/django-haystack/haystack/models.py", line 230, in load_indexes
[Fri Oct 16 10:02:23 2015] [error] ui.setup_indexes()
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/webapps/django/kb/src/django-haystack/haystack/utils/loading.py", line 268, in setup_indexes
[Fri Oct 16 10:02:23 2015] [error] self.build()
[Fri Oct 16 10:02:23 2015] [error] File "/home/kbuzz/webapps/django/kb/src/django-haystack/haystack/utils/loading.py", line 203, in build
[Fri Oct 16 10:02:23 2015] [error] raise ImproperlyConfigured("Model '%s' has more than one 'SearchIndex`` handling it. Please exclude either '%s' or '%s' using the 'HAYSTACK_EXCLUDED_INDEXES' setting." % (model, self.indexes[model], index))
[Fri Oct 16 10:02:23 2015] [error] ImproperlyConfigured: Model '<class 'articles.models.Article'>' has more than one 'SearchIndex`` handling it. Please exclude either '<articles.search_indexes.ArticleIndex object at 0x7f5ce737b4c8>' or '<articles.search_indexes.ArticleIndex object at 0x7f5ce6da66d0>' using the 'HAYSTACK_EXCLUDED_INDEXES' setting.
答案 0 :(得分:0)
与haystack中的doc一样,
您通常会为每种类型的模型创建一个唯一的SearchIndex 希望索引
也许您已为articles.model.Article
定义了两个或更多SearchIndex。请检查SearchIndex中的get_model
。