python - ImportError:无法从“django.shortcuts”导入名称“render_to_response”
问题描述
from django.shortcuts import render_to_response
ImportError: cannot import name 'render_to_response' from 'django.shortcuts' (C:\Users\gtdra\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\shortcuts.py)
当我迁移django-chroniker
到我的 django 项目时出现此错误,我读到render_to_response
自 Django 2.0 以来已被删除,我该如何解决此错误?感谢您
解决方案
render_to_response
不可用django.shortcuts
(render_to_response 快捷方式在 Django 2.0 中已弃用,在 Django 3.0 中已删除。)。你可以render
像下面这样使用
from django.shortcuts import render
def myview(request):
return render(request, 'template.htmll', {'hi': 'hello'})
推荐阅读
- angularjs - 无法使用量角器在 AngularJs 中定位和选择下拉值
- javascript - 如何在下拉菜单上模糊网站
- python - 基于 2 个属性排序
- java - 如何在 keycloak 中的自定义 SPI 中获取电子邮件验证链接
- javascript - 在节点js中的函数调用响应后执行代码
- javascript - Javascript 用户脚本 - 查找和替换:文本节点和 HTML
- android - 图像相机质量很差
- javascript - 尝试设置增量控制器
- docker - Hyperledger Fabric:Cli Bash 无法连接到 orderer;链码未在通道上实例化
- amazon-web-services - Cognito 注销流程未从浏览器中清除 ADFS 的 cookie