Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created July 21, 2008 23:13
Show Gist options
  • Save imownbey/428 to your computer and use it in GitHub Desktop.
Save imownbey/428 to your computer and use it in GitHub Desktop.
def get_object_or_404(klass, *args, **kwargs):
try:
return queryset.get(*args, **kwargs)
except queryset.model.DoesNotExist:
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment