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

这是由于在视图函数中使用了get函数,获取了不存在的数据
例如:数据库中不存在一条name为hello1的数据,使用以下语句访问
message = Message.objects.get(name='hello1')

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

解决方法:
见下图:

 

 点击上图框中的连接后,自动进入debug.py文件的323行,对321行代码修改见下图:数据库

 

 

 

 再次运行:函数

 

 

此时报错信息正常,查询的数据不存在在MAC 和 Linux中不存在这种问题,在 MAC 和 Linux中已经将编码方式默认为 utf8
相关文章
相关标签/搜索