Created
July 21, 2008 23:12
-
-
Save imownbey/427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_object_or_404(klass, *args, **kwargs): | |
queryset = _get_queryset(klass) | |
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