【问题标题】:TypeError: context must be a dict rather than ContextTypeError:上下文必须是字典而不是上下文
【发布时间】:2017-08-18 00:33:34
【问题描述】:

我正在尝试将搜索引擎构建到 django 博客应用程序中,当我运行命令时:

>>> manage.py build_solr_schema

我收到了这个错误:

Traceback (most recent call last):
  File "C:\Users\KOLAPO\Google Drive\Python\Websites\mysite\manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\haystack\management\commands\build_solr_schema.py", line 29, in handle
    schema_xml = self.build_template(using=using)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\haystack\management\commands\build_solr_schema.py", line 57, in build_template
    return t.render(c)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\template\backends\django.py", line 64, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "C:\Users\KOLAPO\Anaconda3\lib\site-packages\django\template\context.py", line 287, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than Context.

怎么了?

注意:我使用 Solr 和 Django-haystack 作为搜索引擎

【问题讨论】:

    标签: python django


    【解决方案1】:

    我认为这个问题已经被 pull request 1504 修复了,但是从那以后好像没有发布过。

    【讨论】:

    • 这是正确的。那是我的公关!他剪切了一个 alpha 版本,您可以使用 pip (pypi.python.org/pypi/django-haystack/2.7.dev0) 获取。你也可以直接从 github 抓取,语法如pip install git+https://github.com/RabidCicada/django-haystack@BRANCHNAME/COMMIT#egg=django-haystack
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-08
    • 1970-01-01
    • 2019-02-01
    • 2017-10-02
    • 2021-04-25
    • 1970-01-01
    相关资源
    最近更新 更多