首页 > Windows开发 > 详细

windows中使用django时报错:A server error occurred. Please contact the administrator.

时间:2020-03-23 13:11:50      阅读:633      评论:0      收藏:0      [点我收藏+]
这是因为在视图函数中使用了get函数,获取了不存在的数据
例如:数据库中不存在一条name为hello1的数据,使用如下语句访问
message = Message.objects.get(name=‘hello1‘)

就会报错 message = Message.objects.get(name=‘boddy1‘)

解决方法:
见下图:
技术分享图片

 

 点击上图框中的链接后,自动进入debug.py文件的323行,对321行代码修改见下图:技术分享图片

 

 

技术分享图片

 

 再次运行:

技术分享图片

 

 

此时报错信息正常,查询的数据不存在

在MAC 和 Linux中不存在这种问题,在 MAC 和 Linux中已经将编码方式默认为 utf8

windows中使用django时报错:A server error occurred. Please contact the administrator.

原文:https://www.cnblogs.com/xiaohaodeboke/p/12551363.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!