How to catch Django DoesNotExist exception 

Joined:
04/09/2007
Posts:
710

December 25, 2009 03:23:36    Last update: December 25, 2009 03:23:51
Suppose User is the model class, this is the code to catch DoesNotExist:

>>> try:
...     u = User.objects.get(name='Django Reinhardt')
... except User.DoesNotExist:
...     print 'Not found!'
...
Not found!
>>>
Share |
| Comment  | Tags
 
Easy email testing with http://www.ximailstop.com