运行 python manage.py build_solr_schema 出现TypeError
来源:互联网 发布:监控摄像头客户端软件 编辑:程序博客网 时间:2024/06/05 03:02
原文出处https://github.com/django-haystack/django-haystack/issues/1519
问题:
运行 python manage.py build_solr_schema 出现如下错误:
TypeError : context must be a dict rather than Context
解决方法:
1.检查haystack是否为最新版(推荐版本(我用的版本)):
Operating system version: Ubuntu 16.04.2 LTS (GNU/Linux 4.8.0-54-generic x86_64)
Search engine version: solr 4.10.4
Python version: 3.5
Django version: 1.11.4
Haystack version: 2.6.1
2.打开 site-packages\haystack\management\commands\build_solr_schema.py文件
打开build_solr_schema.py文件
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_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() ) 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, } return Context
3.重新运行 python manage.py build_solr_schema
显示为:
运行成功,输出schema.xml的代码内容
阅读全文
0 0
- 运行 python manage.py build_solr_schema 出现TypeError
- 运行python manage.py syncdb时出现“cannot connect to MySQL server on 'localhost'”的解决方法
- python manage.py dbshell
- python manage.py runserver启动服务器时出现10013错误
- python manage.py makemigrations 和python manage.py migrate
- Python manage.py shell和 Python 区别
- 运行python manage.py runserver报错现象、原因和解决办法
- 在运行envirtual环境创建项目,python manage.py migrate同步数据库问题
- 出现这个 python: can't open file 'manage.py': [Errno 2] No such file or directory
- 启动python manage.py syncdb后报错
- python manage.py runserver 0.0.0.0:8000
- python django manage.py 命令集合
- python manage.py runserver 0.0.0.0:8000
- django使用python manage.py syncdb注意事项
- django1.6 python manage.py collectstatic
- Django入门:python manage.py dbshell错误
- 运行python 时出现TypeError: obj() takes no parametrs
- 修改manage.py来运行自己的命令
- VS2010中“工具>选项中的VC++目录编辑功能已被否决”解决方法
- Git Bash常用命令
- C++模板(template)
- hibernate单表,一对多,多对多配置文件详解
- C++中struct和class的区别
- 运行 python manage.py build_solr_schema 出现TypeError
- Linux下搭建Web项目运行环境Tomcat+Mysql+Jdk
- XML讲解
- spring中事务配置REQUIRES_NEW不起作用
- checkbox多选显示同级下一个元素的值
- leetcode 561---- ArrayPartition
- BZOJ 2654: tree kruskal 二分
- 华为手机设置状态栏透明 竟出现灰色的背景问题
- MYSQL 操作中文乱码问题