mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-03-16 22:20:31 +00:00
Fixed #148 -- Added compatibility for Django 1.8
Thanks Ben Cole for the report.
This commit is contained in:
parent
81ee120900
commit
89f05790b1
1 changed files with 10 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
|
||||
import django
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
@ -466,8 +467,12 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
add_non_text_to_document(prefix, term, weight)
|
||||
|
||||
# store data without indexing it
|
||||
if django.VERSION < (1, 7):
|
||||
model_name = obj._meta.module_name
|
||||
else:
|
||||
model_name = obj._meta.model_name
|
||||
document.set_data(pickle.dumps(
|
||||
(obj._meta.app_label, obj._meta.module_name, obj.pk, data),
|
||||
(obj._meta.app_label, model_name, obj.pk, data),
|
||||
pickle.HIGHEST_PROTOCOL
|
||||
))
|
||||
|
||||
|
|
@ -664,7 +669,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
matches = self._get_enquire_mset(database, enquire, start_offset, end_offset)
|
||||
|
||||
for match in matches:
|
||||
app_label, module_name, pk, model_data = pickle.loads(self._get_document_data(database, match.document))
|
||||
app_label, model_name, pk, model_data = pickle.loads(self._get_document_data(database, match.document))
|
||||
if highlight:
|
||||
model_data['highlighted'] = {
|
||||
self.content_field_name: self._do_highlight(
|
||||
|
|
@ -672,7 +677,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
)
|
||||
}
|
||||
results.append(
|
||||
result_class(app_label, module_name, pk, match.percent, **model_data)
|
||||
result_class(app_label, model_name, pk, match.percent, **model_data)
|
||||
)
|
||||
|
||||
if facets:
|
||||
|
|
@ -780,9 +785,9 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
matches = self._get_enquire_mset(database, enquire, start_offset, end_offset)
|
||||
|
||||
for match in matches:
|
||||
app_label, module_name, pk, model_data = pickle.loads(self._get_document_data(database, match.document))
|
||||
app_label, model_name, pk, model_data = pickle.loads(self._get_document_data(database, match.document))
|
||||
results.append(
|
||||
result_class(app_label, module_name, pk, match.percent, **model_data)
|
||||
result_class(app_label, model_name, pk, match.percent, **model_data)
|
||||
)
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue