Login

Tag "objectdoesnotexist"

Snippet List

View decorator to convert DoesNotExist (ObjectDoesNotExist) exceptions into Http404 exceptions

A decorator that can be applied to your views to turn ObjectDoesNotExist exceptions into Http404 exceptions. This means people will see a "Page not found" error rather than an "Internal Server Error" when they are request something that does not exist in the database. Example: @raise_404 def show_event(request, id): event = Event.objects.get(id) return render_to_response('events/show_event.html', { 'event' : event })

  • error
  • exception
  • 404
  • errors
  • exceptions
  • objectdoesnotexist
  • doesnotexist
Read More

2 snippets posted so far.