django-haystack2.6.1 does not support django1.11.2?

240 views
Skip to first unread message

赵永峰

unread,
Jun 27, 2017, 7:33:32 PM6/27/17
to django-haystack
my development environment is:
python3.4 32bit
django1.11.2
django-haystack2.6.1
pysolr3.6.0

when I run manage.py build_solr_schema command
django raise a error:TypeError: context must be a dict rather than Context.

I look up the source code of haystack:

def build_context(self, using):
backend = connections[using].get_backend()

if not isinstance(backend, SolrSearchBackend):
raise ImproperlyConfigured("'%s' isn't configured as a SolrEngine)." % backend.connection_alias)

content_field_name, fields = backend.build_schema(
connections[using].get_unified_index().all_searchfields()
)
return Context({
'content_field_name': content_field_name,
'fields': fields,
'default_operator': constants.DEFAULT_OPERATOR,
'ID': constants.ID,
'DJANGO_CT': constants.DJANGO_CT,
'DJANGO_ID': constants.DJANGO_ID,
})

def build_template(self, using):
t = loader.get_template('search_configuration/solr.xml')
c = self.build_context(using=using)
return t.render(c)

I thought the t.render(c) function cause the TypeError,the param maybe a dict,not a Context instance.

what should I do about this?

Davide Galletti

unread,
Nov 25, 2017, 2:55:59 PM11/25/17
to django-haystack
Had the same problem with Django 1.11.7 and patched build_context to return a dict:
    return {
Reply all
Reply to author
Forward
0 new messages