TypeError at /post/ render_to_response() got an unexpected keyword argument 'context_instance'

Exception Type: TypeError at /post/
Exception Value: render_to_response() got an unexpected keyword argument ‘context_instance‘https://stackoverflow.com/questions/39629793/typeerror-at-post-render-to-response-got-an-unexpected-keyword-argument-con

formtools not supported the Django 1.10 version please downgrade your Django release for the workaround.

https://github.com/django/django-formtools/issues/75

I solved it by some changes in lib/python3.5/site-packages/formtools/preview.py file. Here I first changes render_to_response to render and then removed context_instance=RequestContext(request) from argument. Suppose post_post method now look like:

 def post_post(self, request):
        """
        Validates the POST data. If valid, calls done(). Else, redisplays form.
        """
        form = self.form(request.POST, auto_id=self.get_auto_id())
        if form.is_valid():
            if not self._check_security_hash(
                    request.POST.get(self.unused_name(‘hash‘), ‘‘),
                    request, form):
                return self.failed_hash(request)  # Security hash failed.
            return self.done(request, form.cleaned_data)
        else:
            return render(request, self.form_template,
                self.get_context(request, form))

It looks like it was already fixed in their repository:

https://github.com/django/django-formtools/blob/master/formtools/preview.py#L88

in this commit:

https://github.com/django/django-formtools/commit/46b6839fb0063fa10ffb896ce80f7155ca7a9f6e

Uninstall django-formtools (pip uninstall django-formtools) and install the library using this this pip command instead:

pip install -e git+git://github.com/django/django-formtools#egg=django-formtools

TypeError at /post/ render_to_response() got an unexpected keyword argument 'context_instance'

时间: 2024-10-01 02:31:38

TypeError at /post/ render_to_response() got an unexpected keyword argument 'context_instance'的相关文章

django2.1发生Django TypeError: render() got an unexpected keyword argument 'renderer

1. 修改 xadmin 源代码1.在Python终端输入命令help(‘xadmin’) 查看xadmin安装位置 得到如下输出 FILE /root/anaconda3/envs/learndjango/lib/python3.5/site-packages/xadmin/__init__.py122.进入xadmin安装路径,编辑xadmin/views/dashboard.py, 搜索所有xadmin 下的代码,有通通给这个方法加参数 renderer=None #render() go

TypeError: __init__() got an unexpected keyword argument 'strict'

使用requests发请求时发生报错 TypeError: __init__() got an unexpected keyword argument 'strict' 莫慌,不是你代码写错了,是因为请求模块requests不是最新的 只需要 pip install requests --upgrade 就OK了 TypeError: __init__() got an unexpected keyword argument 'strict' 原文地址:https://www.cnblogs.c

记录 TypeError: render() got an unexpected keyword argument 'renderer' 错误

在网上看到MXShop这个项目,适合Python, Django + drf 进阶的,其中遇到 TypeError: render() got an unexpected keyword argument 'renderer', 在百度一番后发现是Django集成DjangoUeditor,才导致这个错误的.网上有什么资料都是去改Django的源文件,但是我觉得这样很不好,因为部署到新环境的时候,都要手动去改一下Django源文件,这样太麻烦了 所以打算在DjangoUeditor上找原因,最后

Python报错:TypeError: __init__() got an unexpected keyword argument 'io_loop' 原因及解决方案

今天打开一个Python文件时,报错提示: TypeError: __init__() got an unexpected keyword argument 'io_loop' 明明是从旧电脑上拷贝到新电脑上的文件,之前运行是OK的,新电脑上运行怎么就报错了呢? 错误原因: 配置python环境时,默认tornado版本是最新的版本(恰好我新电脑重新配置了python环境,所以安装了最新版本),但是在4.0版本之后就废弃了io_loop参数. 解决方案: 1. 先卸载当前安装的tornado p

【Django Rest Framework】TypeError: __init__() got an unexpected keyword argument 'name'

前端Vue问题描述: 通过面包屑导航,无法获取导航分类对应商品列表 后端问题描述:# 报错提示 File "D:\Envs\vueshop\lib\site-packages\django_filters\filterset.py", line 258, in form Form = self.get_form_class() File "D:\Envs\vueshop\lib\site-packages\django_filters\filterset.py",

senlin __init__() got an unexpected keyword argument 'additional_headers'

从senlin源码重新编译更新了服务,然后执行 senlin的 cli就遇到了错误: __init__() got an unexpected keyword argument 'additional_headers' 谷歌了一下,找到这份开发者的聊天日志: http://eavesdrop.openstack.org/irclogs/%23senlin/%23senlin.2016-08-16.log.html 知道是client没有更新的缘故,于是我执行了: $sudo pip instal

Django--bug--__init__() got an unexpected keyword argument 'qnique'

建立模型之后,执行迁移,报如下错误: __init__() got an unexpected keyword argument 'qnique' 错误原因:模型的属性的约束添加错误,这种错误一般就是单词拼写,参数少传的粗心导致的,细心点即可避免. 解决方案:修改模型的约束, 执行: python manage.py makemigrations python manage.py migrate 迁移成功. Django--bug--__init__() got an unexpected ke

Xadmin添加用户小组件出错render() got an unexpected keyword argument 'renderer

环境: Python 3.7 Django 2.1 Xadmin 原因: render函数在django2.1上有变化 解决方法: 进入xadmin安装路径,编辑xadmin/views/dashboard.py 36 #render() got an unexpected keyword argument 'renderer' 37 #修改bug, 添加renderer 38 39 def render(self, name, value, attrs=None, renderer=None)

login() got an unexpected keyword argument 'extra_context'

环境:xadmin   django2.0  python3.7.4 操作登录login()或者注销logout()报以上错误的解决办法如下: 在xadmin的views/website.py中 修改如下: from django.contrib.auth.views import login from django.contrib.auth.views import logout login() got an unexpected keyword argument 'extra_context