Skip to content

Instantly share code, notes, and snippets.

@victorono
Last active December 28, 2015 14:59
Show Gist options
  • Save victorono/7519093 to your computer and use it in GitHub Desktop.
Save victorono/7519093 to your computer and use it in GitHub Desktop.
Show page 404 for register not found django
def not_found(method):
def wrap(*args, **kwargs):
from django.core.exceptions import ObjectDoesNotExist
from django.http import Http404
try:
return method(*args, **kwargs)
except ObjectDoesNotExist, ex:
raise Http404(ex.message)
return wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment