djangosnippets.org: Latest snippets tagged with 'doesnotexist'http://djangosnippets.org/tags/doesnotexist/2009-09-26T03:58:57.691763-05:00View decorator to convert DoesNotExist (ObjectDoesNotExist) exceptions into Http404 exceptions
2009-09-26T03:58:57.691763-05:00jammycakeshttp://djangosnippets.org/snippets/1743/<p>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.
</p>
<p>Example:
</p>
<pre><code>@raise_404
def show_event(request, id):
event …</code></pre>
Freely redistributable