fankcoder
V2EX  ›  Python

django 不会正常报错了

By fankcoder at 2018 年 5 月 9 日 · 1913 次点击

所有的错误统一都返回 "in exception"

比如我在 views.py 里随便乱写一行也是返回 in exception

正常例子: def test(request): ret = {'test':1} return HttpResponse(json.dumps(ret), content_type="application/json")

返回 in exception 例子: def test(request): asdfasdb #乱写的错误 ret = {'test':1} return HttpResponse(json.dumps(ret), content_type="application/json")

我的 django 版本

import django django.VERSION (2, 0, 2, 'final', 0)

debug 也是开的 DEBUG = True

麻烦各位大佬了,今天冒了两次泡哈哈

2 条回复  •  2018-05-09 17:46:48 +08:00
fankcoder
   1
fankcoder  
OP
   2018 年 5 月 9 日
哇 ,代码格式瞎了。。。
正常例子:

def test(request):

ret = {'test':1}

return HttpResponse(json.dumps(ret), content_type="application/json")

返回 in exception 例子:

def test(request):

asdfasdb #乱写的错误 ret = {'test':1} return HttpResponse(json.dumps(ret), content_type="application/json")
fankcoder
   2
fankcoder  
OP
   2018 年 5 月 9 日
返回 in exception 例子:

def test(request):

asdfasdb #乱写的错误

ret = {'test':1}

return HttpResponse(json.dumps(ret), content_type="application/json")
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
© 2026 V2EX · 22ms · 3.9.8.5