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})
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.
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
3 matches
Mail list logo