Re: How to import DoesNotExist exception ???

2008-12-09 Thread Sérgio Durand
from tutorial part 03: from django.http import Http404 # ... def detail(request, poll_id): try: p = Poll.objects.get(pk=poll_id) except Poll.DoesNotExist: raise Http404 return render_to_response('polls/detail.html', {'poll': p})

Re: How to import DoesNotExist exception ???

2008-12-08 Thread Info Cascade
I just want to catch the exception thrown when the query returns nothing. Thanks, that seems to have done the trick. [EMAIL PROTECTED] wrote: > I'm not sure where you got that code snippet from, but DoesNotExist is > an attribute on model classes, so that shoul read: > > except Tag.DoesNotExist.

Re: How to import DoesNotExist exception ???

2008-12-08 Thread [EMAIL PROTECTED]
I'm not sure where you got that code snippet from, but DoesNotExist is an attribute on model classes, so that shoul read: except Tag.DoesNotExist. On Dec 8, 2:52 pm, Info Cascade <[EMAIL PROTECTED]> wrote: > How do I import the DoesNotExist exception? > > This doesn't seem to work:> from