捕获任何不存在的错误 [英] Catching Any DoesNotExist Error

查看:54
本文介绍了捕获任何不存在的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django 1.7.通常,您可以在模型中捕获 DoesNotExist 异常,例如;

I am using Django 1.7. Normally you can catch DoesNotExist exception over your model like;

try:
   ...
except model.DoesNotExist, den:
   ...

我想捕获任何 DoesNotExist 异常.我真的不想关心它的模型.实际上,我真的也不知道哪个模型 DoesNotExist 正在通过代码段.我的意思是,我不知道该模型.

I want to catch any DoesNotExist exception. I really don't want to care about its model. Actually, I really don't know which model DoesNotExist is passing through the code piece either. I mean, I am not able to know the model.

所以我必须以某种方式捕获任何 DoesNotExist 错误.

So I have to catch any DoesNotExist error somehow.

是否有办法在 Django 中捕获任何 DoesNotExist 错误?

Is there a way to catch any DoesNotExist error in Django?

推荐答案

DoesNotExist 异常是 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆