1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #21619 -- Made SingleObjectMixin.get_object catch a more precise exception.

Thanks to Keryn Knight for the report.
This commit is contained in:
Peter Harley
2013-12-14 23:15:35 +00:00
committed by Baptiste Mispelon
parent a1bc3683ff
commit cdd6617da6
5 changed files with 29 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
from __future__ import unicode_literals
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.http import Http404
from django.utils.translation import ugettext as _
@@ -50,7 +50,7 @@ class SingleObjectMixin(ContextMixin):
try:
# Get the single item from the filtered queryset
obj = queryset.get()
except ObjectDoesNotExist:
except queryset.model.DoesNotExist:
raise Http404(_("No %(verbose_name)s found matching the query") %
{'verbose_name': queryset.model._meta.verbose_name})
return obj