render_to_string() got an unexpected keyword argument 'context_instance'

来源:16-2 修改代码适配python3.6和django1.11

ymfsder

2017-11-15

这是控制台信息

System check identified no issues (0 silenced).

November 15, 2017 - 13:56:20

Django version 1.11.7, using settings 'OnlineEducation.settings'

Starting development server at http://127.0.0.1:8000/

Quit the server with CTRL-BREAK.

Internal Server Error: /xadmin/courses/course/

Traceback (most recent call last):

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\core\handlers\exception.py", line 41, in inner

    response = get_response(request)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response

    response = self._get_response(request)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\core\handlers\base.py", line 217, in _get_response

    response = self.process_exception_by_middleware(e, request)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\core\handlers\base.py", line 215, in _get_response

    response = response.render()

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\response.py", line 107, in render

    self.content = self.rendered_content

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\response.py", line 84, in rendered_content

    content = template.render(context, self._request)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\backends\django.py", line 66, in render

    return self.template.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 207, in render

    return self._render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 199, in _render

    return self.nodelist.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 990, in render

    bit = node.render_annotated(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 957, in render_annotated

    return self.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\loader_tags.py", line 177, in render

    return compiled_parent._render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 199, in _render

    return self.nodelist.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 990, in render

    bit = node.render_annotated(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 957, in render_annotated

    return self.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\loader_tags.py", line 177, in render

    return compiled_parent._render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 199, in _render

    return self.nodelist.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 990, in render

    bit = node.render_annotated(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 957, in render_annotated

    return self.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\loader_tags.py", line 72, in render

    result = block.nodelist.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 990, in render

    bit = node.render_annotated(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 957, in render_annotated

    return self.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\loader_tags.py", line 72, in render

    result = block.nodelist.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 990, in render

    bit = node.render_annotated(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\base.py", line 957, in render_annotated

    return self.render(context)

  File "C:\Users\ymfsd\Envs\OnlineEducation\lib\site-packages\django\template\library.py", line 203, in render

    output = self.func(*resolved_args, **resolved_kwargs)

  File "E:\PyCharm\DjangoOnlineEducation\extra_apps\xadmin\templatetags\xadmin_tags.py", line 24, in view_block

    result = block_func(context, nodes, *args, **kwargs)

  File "E:\PyCharm\DjangoOnlineEducation\extra_apps\xadmin\plugins\excel.py", line 16, in block_top_toolbar

    nodes.append(loader.render_to_string('xadmin/excel/model_list.top_toolbar.import.html', context_instance=context))

TypeError: render_to_string() got an unexpected keyword argument 'context_instance'

[15/Nov/2017 13:56:25] "GET /xadmin/courses/course/ HTTP/1.1" 500 365346


写回答

2回答

bobby

2017-11-16

你通过qq群找到我 给我发个qq消息 我给你看看

0
0

柿饼小星

2018-01-04

问题解决了么 遇到一样的报错...

0
1
bobby
django版本不一致造成的 最好根据课程的版本来
2018-01-08
共1条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程